I have a PIC 16F887A connected to the serial port. I want it to lit a green led when it receives 0x01 and lit a red led when it receives 0x00 from pc. I send the characters from a C# windows forms application, the PIC itself is programmed with CCS C. Can you please tell me what i'm doing wrong as the codes below don't work?
Edit: By doesn't work i mean it lits the red led in both cases.
C# Code
CCS C Code
OmertaOmerta
1 Answer
If it receives 0x00 in both cases, it is likely that you have a baud rate mismatch, even a slight one. After detecting a start bit, the PIC might be seeing the first 7 zeroes and think it saw 8, going you 0x00 in both cases. I would try transmitting from the PIC and PC and watching the lines on a scope to ensure they are running the same speed. You can also try continuously transmitting 0xAA to get an eye pattern (10101010) and comparing the two signals.
Nathan WiebeNathan Wiebe
Not the answer you're looking for? Browse other questions tagged c#cserial-portpic or ask your own question.
Oct 28, 2018 - Learn to send/receive data to/from PIC USART with MikroC Pro for PIC compiler and interface your PIC with a PC RS232 serial connection. By Bitahwa Bindu Flowcode for PIC, Tutorials Flowcode, Flowcode V5, Microcontroller, PIC, PIC Communication, RS232, Tutorials, USB, USB CDC Figure 1: USB Communication using PIC18F4550 Many computers especially portable ones do not have a serial port (COM Port) anymore.