PDA

View Full Version : PicBasic Pro PIC18LF45J10 Hserin2 problem



MountainA
- 9th April 2014, 01:41
Hello all

I am having problems reading a configurable serial port of a PIC 18LF. I am able to send data but unable to make sense of any of the data received. I have attached the cut down code I have been working on)

Observations:

The Define HSER2_BAUD instruction does not appear to set up the Pic's baud rate generator, I have to do this manually to get it working correctly.
Once configured I am able to send a small test string "hello world" however it is proceeded by a zero. This is not too much of a problem, I am sure I can sort something out to resolve that issue.
When I type a character to be received by the pic through an RS232 interface, the characters received are unintelligible.
Things I have checked.

I have checked using a scope that the RS232 driver is sending the data correctly to the pick. The letter "A" or any other character is observed to be arriving at the UART of the pic correctly and in the right phase (not inverted)
I have sent the received data to an LCD to be displayed as well as sending the received character out to a terminal, in both circumstances the data is unintelligible.
I have looked directly at the RCREG2 to ensure there was no problem there but what I see is the same unintelligible data.
I have checked that I have the correct re-mappable pin for the UART. (The RX interrupt does not work if I select any other pin, in other words the UART is reacting to the data received)
I have set BAUDCON2.3 = 1 to enable the UART to wake up from sleep mode, without this bit set, the UART does not wake up the PIC.
I have spent some time on this now and I am clearly not getting anywhere. I am about to check UART1 operation to confirm if I have the same problem but as I have limited access to this port (it will be talking to another device) it’s a little more complicated. In the meantime if anyone could shed some light on the matter I would be very grateful.

Cheers
Ant :eek:

HenrikOlsson
- 9th April 2014, 06:19
Hello,
Have you checked the accuracy of the oscillator, perhaps it's too far off from 4MHz to accurately generate the baudrate timing? Also, have you checked the timing/baudrate of the sending device and verified that it is indeed as expected.

Have you tried receiving without having the PIC in low power mode?

/Henrik.

tasmod
- 9th April 2014, 08:08
You've set the chip sleep to Internal Oscillator at 4MHz but according to the datasheet this chip only has 31kHz oscillator available internally.

I assume you are also using an external switched xtal.

MountainA
- 10th April 2014, 00:39
Hello Rob and Henrik

Thanks for your replies. old Murphy’s Law is still alive and well..! No sooner had I posted my thread I discovered my fault. Rob you are right on the money, I clean forgot that all the clocks on the processor are disabled while it is in sleep. Reading through the documentation, on the UART, I read that BAUDCON.1 allows the RX pin to operate as a change state interrupt and just assumed that the processor would wake up on the mark and would be alive and ready to read the data on the RX pin. Clearly this was not the case, I had not accounted for the oscillator start up time.

Thanks for your input, I should have sent my post earlier, I would have got the help I needed sooner