Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Questions about UART and SPI

Status
Not open for further replies.

treyz

Member level 5
Joined
Sep 26, 2012
Messages
93
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
2,065
Hi,

I am working on a big project and one bit of this project is to send a frame from a PC via RS232 to a PIC 18f4680 and then send that same frame to another PIC via SPI.

I am wondering, is there any spec,timing issues I should be worried about? Do I have to interrupts,or not?do I have to use timers? Or the all things will work without any problem?

Thanks
 

I have not worked with PIC, but hardware modules for both UART and SPI should be available inside the MCU. You could make it by software (so called "bit banging"), but it would be better to stick to the hardware implementation, by setting proper registers and read - write serial data via hardware buffers.
As for interrupts, if you have big packets (especially for UART which is slower), it would be better to do this with interrupts.
 

Hi

Thanks for getting back to me that fast.

All I have to be worried about is the interrupts, I don't need to use some delays or anything else?
My packet is very long, is has some delimiters: stx......etx

I am trying to check if the pic detects the right incoming data by using a led. But it doesn't light on. I have checked with the same LED if there was something in the buffer and it works fine. That's why I am wondering if there is not a matter of timing?
Here is my piece of code:
.
.
.
while(1)
{
// Main function of chip is to receive data from PC via RS232, and send to slave via SPI - and that's it.
// So after initialization of registers, wait until there's data on RS232 line.
while (!DataRdyUSART()); // wait until data
result[j] = ReadUSART(); // Get the character received from the USART
if (result[j] == 0x02) // Right data coming in?(STX)
{
PORTD = 0x31;
//for (i=0; i<5; i++)
// {
// Delay10KTCYx(0);
// PORTD = 0x30;
// }
.
.
.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top