Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 
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.

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.
 
Hello,
I need to create a UART interrupt on a PIC18F4550. I need to exit a loop when I receive data via the serial port and I haven't used any interrupts in my small projects. I use the PIC SIMULATOR IDE. Can you explain to me how to configure the registers? I attach the code. Thanks
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:

Latest threads

New Articles From Microcontroller Tips

Back
Top