Sunday, March 18, 2012

Micro controller Networking - UART to SPI bridge

There are many parts used in embedded systems.In most cases,we have to transfer data between these components.In this tutorial we're going to look how to receive data from UART module in a PIC micro and transfer those data to another component using SPI module.Using this method we can transfer single input to multiple receivers because we can use more than one component in SPI.

In here,PIC16F887 micro controller is used as the UART receiver and it'll send the received data via it's SPI module.MikroC PRO is used for the writing the firmware.You can download the FREE(with some limitations) version from,

MikroC PRO Download Page

This is the code used.First we initialize UART module to work at 9600bps.
Then we initialize SPI module.Then the code is to check whether there is data coming to UART module and if so,just relay them to SPI module.The last line will send received data again to another UART receiver via UART Tx pin.

You can find more info on these modules form MikroC knowledge base.

SPI Library

UART Library

void main() {
char receive;
if (UART1_Data_Ready() == 1) {
receive = UART1_Read();

Circuit with PIC16F887 Slave with this PIC16F887 Master:(Click on image to get high resolution schematic)

In the next post,we'll build a simple motor controller slave with this :D

1 comment:

  1. i am using this tow software for my development. wish you all the best