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;
UART1_Init(9600);
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_END,
_SPI_CLK_IDLE_HIGH, _SPI_LOW_2_HIGH);
while(1){
if (UART1_Data_Ready() == 1) {
receive = UART1_Read();
SPI1_Write(receive);
UART1_Write(receive);
}
}
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