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.

PIC Serial Communication reconnect problem

Status
Not open for further replies.

kad_911

Member level 2
Joined
Nov 15, 2009
Messages
52
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
earth
Activity points
1,623
Hi
Im serially communicating with a device using a PIC18Fxx microcontroller.
the program initializes uart at the beginning of the code.

the pic continuously sends commands to the device and the device acknowledges with blinking LEDs.
the problem is, when I reboot the PIC, the serial communication stops. I have to unplug and replug the serial cable in order to make it communicate again.

I tried experimenting with the TX RX and GND. It seems that after rebooting, ANY connection (TX, RX or GND) will need to be disconnected and reconnected before the device to identify the incoming commands...



any idea why this happens?
How can I solve this?

Thanx.
 

Hi,

You say serial comms stops, but where ? - is it actually the Pic not sending out or is it the 'device' not repsoning ?

Does the device return anything on the Pics RX line, have you tried leaving that unconnected ?

Perhaps show your USART init and running code and details of your 'device'
 
The PIC doesn't stop sending data, its actually the other device that doesn't recognize the commands sent from the PIC.
when the command is sent from the PIC, the device responds with a reply byte to the PIC.

I didn't mention that because even if the PIC is programmed only to send commands and ignoring the RX from the device, the same issue arises.
And yes I tried with the RX of the PIC unconnected.

anyway its a RFID reader (DL940)
 

Hi,

Not familiar with RFID readers and cannot find anything on the one your specify.

Does that modude have a reset pin that you can signal from the pic ?
 

Unfortunately no. I tried with separate supplies to the device and PIC. after rebooting the PIC, even if I reboot the RFID device manually, the serial connection doesn't start. every time I have to reconnect the serial cable... :(
 

Hi,

The only other things I would check is the cable and its length you are using for the data transfer .

Is it a direct 5V connection, assuming your RFID is also 5V and not a 3v3 device?
At 5v you are very limited in the distance you can reliably communicate, a shielded cable is advisable.
Or are you using a Max232 converter ?

You could perhaps replace the RFID with another Pic chip and try and simulate the RFID which should make it easier to locate where the problem is.
Also controlling the RFIDs power line with a pic pin and transistor so the RFID always powers on after the the Pic has booted and but before the Pic transmits anything to it.
 
Try to write 1 and then 0 to Tx and Rx pins after a reset.
 
Last edited:

Thanx for the replies.
I tried writing 1 and 0 to TX and RX after reset. it didnt work... :(

And the PIC is working in 3.3V but the RFID reader is 5V. There is a MAX3232 in the serial circuit of the PIC.
If the voltage is the problem, How can it work when the cable is re plugged?
 

the original code is huge.. its a huge collection of codes..
anyway I tried with a test code, where in the main function, it only has:

while(TRUE)
{
putc(0x04); putc(0x00); putc(0x01);
delay_ms(200);
}


Thats it.. even with that, it doesn't work..
 

Hi,

Have to ask as you only refer to one max3232, but you have also got a max232 or max3232 on the +5v rfid device ?

Also what type and length of cable are you using between the two units ?
 

ok now whats this with the MAX232...? because it works when I connect it the 1st time AND when I reconnect the cable...

The length of the cable is 4 feet shielded male-female cable...

And if im using pullups, what resistors should i use?


EDIT: I changed the serial cable to less than 10cm.. still the same. and should I pullup to 5v?
 
Last edited:

If you are using MAX232 or MAx3232 use 10k resistors for pullup. MAX232 cannot be connected to your device (mcu) you have to use MAX3232 to connect your mcu. If your device is 3.3v then pullup to 3.3v
 
RFID device is working in 5V and the MCU is working in 3.3V .................... So I should pullup to 3.3V ?
wouldn't that give a direct 3.3v input to the device RX line??

- - - Updated - - -

Can any1 tell me how to make a 3.3V TTL output become a 5V TTL output???
a circuit diagram would be much appreciated..

- - - Updated - - -

wait wait... I think the signal goes through 2 MAX ICs... Cuz my PIC has 1 and the device has its own MAX232... :/ :/ :/
im confused how it worked so far...!!
Does a MAX232 take a 3.3V TX as a input signal?
 

I think MAX232 doesn't take 3.3v but 5v. Its inpyt output will also be 0-5v.
if you use MAX3232 it takes 3.3v and its input/output is 0-3.3v
 

Hi,

You do not say which 18F chip you are using ,but many do run on 5V.

If yours is capable of 5v why not run it on that so you can directly connect to the RFid ( at least until you prove where the fault is)
For 4 ft you do not need rs232.
 

Hello, Thanx for all the replies. I found the problem and got it fixed. It was a problem in the Serial intterupts.. Disabling and enabling it before the main loop fixed it.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top