NEXTION - PIC16F877A

Jtomas

New Member
Hello everyone,
I'm glad I found this site, I would appreciate if someone has made a connection between a Nextion screen and a PIC, using PIC SIMULATOR IDE, I'm stuck and I'm not able to capture the codes of the buttons that I've entered on the NEXTION screen from the PIC. I'm able to send data from the PIC to the Nextion but not the other way around. I'd appreciate some help.
Thank you very much.
 
Its really the ONLY way when using the UART.. Its not hard to set up an interrupt to fill a buffer.

In my setup I normally read ASCII.. So I would send 1,XX,XX,XX,CRLF where XX is my data in text.
Only when the LF is received I sort out the Data back into integers.

That way I don't have to worry about missing any data.

Code:
set interrupt to receive 1 byte continuously
set the index to 0 
set sync run to 1

interrupt
    if LF is received traverse the data to get the data out.
     if sync run = 1  set sync run to 0 then exit 
     Fill buffer byte by byte     
     clear the buffer set the index to 0.
     clear
    set data received flag
all done
 

I agree, I do much the same - and the MCC even builds interrupt driven serial routines for you.

Like you I wait for LF and then set a flag showing data has been received, I also don't save either CR or LF in the buffer.
 
I'm sorry but I can't insert a uart+interrupts code in the example code you left, this is due to the lack of formatting of the text (text indentation) and the use of "goto" which hasn't been used in programming for more than 30 years. Due to lack of time I have adapted an old code to your needs. To see which registers are used you only have to consult the attached library. Anyway, if you have problems later I will review the code I have uploaded and remove all the fluff to leave it at what is strictly necessary.

Note: I forgot to comment on the code it does is to receive a key press from a serial console and forward it to the same, that is, the well-known hardware key echo.
 

Attachments

  • Ejemplo Uart RS232.bas
    3.6 KB · Views: 4
  • _Pic18F26K22Library.bas
    46.4 KB · Views: 2
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…