Hi;
I am using MPLABX, PIC18f2520 and assembler. I have 2 PIC182520 talking to each other with SPI. Master PIC gets data from UART module. Then transmit the same data through SPI module to Slave PIC. Slave PIC gets that data and then transmit it through UART.
Initially instead of sensor I use a serialport program (realterm) both at the begining and end of the transmission line to emulate hardware and software. Whenever i send a data i am receiving a different data.
In the datasheet of PIC18f2520 it is written that "Before enabling the module in SPI Slave mode, the clock line must match the proper Idle state. "
I am enabling the slave PIC's SPI module as slaveSPI at the begining of everything. So i dont check if the clock line in proper idle state. (And i didnt understand how to check and implement this "must case" ) Does this could cause an error ?
There may be a hardware problem. We can´t verify this becaous you didn´t send schematic and hardware informations.
There may be a software problem. We can´t verify this, because you didn´t send your code(s)
And there may be as setup or clock accuracy problem.
As with every UART problem: The first thing to look at is the baud rate: Are all baud rates within specification?
Whenever i send a data i am receiving a different data.
This is a vague description.
Tell us what byte you send, and what byte you recieve. Is this stable or do you recieve different bytes while sending the same byte?
--> tell us the values.
Both UART and SPI can simply be debugged with a dual channel scope.
--> show us scope pictures.
Hi.
Thanks for the answers. I will elaborate my problem with hardware and software details as soon as possible. But in the last working hour of day i found out that one of my RS232-TTL converters may not working properly.
This is the scheme i use for USB-RS232-TTL conversion. I need to be sure if it is true, conceptually? I use 2 of them for UART communications. Output voltage levels differ significantly. One is outputting approximately 12volts the other is barely giving 5volts.
But yes, you need to convert the PCs serial port voltage from nominally +12/-12V down to 0V/+5V before sending it to the PIC and the reverse to send from PIC to PC again.
There are devices that convert USB directly to TTL (PIC) voltages, in fact most USB serial adapters do that then internally step the voltage up to RS232 levels before it reaches the 'D' connector. Maybe you have one USB-RS232 adapter and one USB-TTL adapter.