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.

UART-SPI interface Problem

Status
Not open for further replies.

kemalkemal

Member level 1
Joined
Jan 27, 2013
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,672
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.
UART-SPI.jpg
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 ?
 

Hi,

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.

Klaus
 

Also, please explain how you have interfaced the PC to the PIC at each end. Are you using level translators (RS232 <> TTL) to match the voltages?

Brian.
 
  • Like
Reactions: Garyl

    Garyl

    Points: 2
    Helpful Answer Positive Rating
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.
USB-SER.jpg
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.
 

Hi,

Even more confusing.
* no SPI anymore, but now USB
* why do you use "two of them"?
* No idia where you measure 12V or 5v...

Impossible to help

Klaus
 

Agreed....

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.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top