Pregunta

I have a project in which I am trying to send data from an android phone to a pic18f4525 through a bluetooth device. Currently, I am just trying to get the pic to recognize simple letters like an 'A'.

From what I understand, when the pic receives the data through PORTC.7 (RX pin), it will store the 8-bit information into the RCREG register and then I all have to do is read the data. I know the pic is receiving the data as the receive flag is being set. Also, I hooked a scope to the receive pin of the pic and it is receiving the correct 01 sequences.

My question is, how do i read the RCREG register to access the information? From what I can tell, I can just use ReadUSART from usart.h however this header file will not compile for me so I am trying to access this data without that header file. Is there a way to do this? I have tried just storing the data directly (i.e. value = RCREG) and I can 'read' the register (the receive flag gets reset so I know I'm reading it) but the pic always thinks the value is 0xFF no matter what I send.

I am using MPLAB version 8.85, with the ICD2, and the CC8E compiler. Any help as to how read the data would be greatly appreciated. I have also completely read the data sheet for using usart on the pic, read through the compiler manual, and did many searches on this topic to no avail.

Thanks for your help.

Update:

DONE!!! After another few hours of messing around with it I finally got it to work. It was in fact a baud rate issue. Thank you for all your help!

¿Fue útil?

Solución

What you are doing should work. This sounds like a baud rate mismatch (somehow you may have neglected to set the BRG register or miscalculated the value that goes in it.) I would try writing to TXREG, triggering a write on the TX pin that you can catch on a scope and verify that the actual baud rate is the same as what is coming in on RX.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top