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.
 
Thanks Dogflu66,
I entered the function and it worked, I left the UART initialization at 1000ms. because I had already tried to modify it without obtaining good results.

Thank you very much.
 
Hello,
Do you have a solution for this problem? I would not be interested in creating a function to represent the messages sent to the Nextion Screen, I only have a String variable declared.
Thanks.
 

Attachments

  • Captura de pantalla 2024-10-12 010823.png
    Captura de pantalla 2024-10-12 010823.png
    10.6 KB · Views: 60
  • LOOP_CAT_v1_11102024.bas
    7.5 KB · Views: 53
Too many strings... Ask yourself if you need all the strings.

put strings into CODE space and pull them one by one when you need them.

read the code byte by byte and fill strings when needed... microcontrollers are never really ram abundant.. compromises are needed.

DogFlu66 I can't seem to see a way of storing constants.. Come of Vlad using code space would be an ideal instead of using up data space
 
I don't know what you mean, I have compiled the program you left and it is both in RAM and in flash under 40% in use and it doesn't give me any error. I recommend that you update the IDE because the strings have been greatly improved. Variables can be saved in flash in several ways, the simplest is to declare them with Const.

'TxT
Const Tex1 = "BANDA..."
Const Tex2 = "t2.txt="
Const Tex3 = "POSICIONANT..."
Const Tex4 = "ÿÿÿ"

'Motor position at end of stroke

'ms_Nextion
value = Qt + "" + Qt
value = Qt + Tex3 + Qt
UART_Write Tex2, value, Tex4
WaitMs 200
 

Attachments

  • v968.jpg
    v968.jpg
    77.6 KB · Views: 69
Hello,

Due to insufficient memory on the PIC16F877A I have switched to the PIC18F4520 and the programmer I used until now, the K150, gives me an error. I have been googling and if I am not mistaken it does not support this type of PIC, although the software recognises them but gives an error when recording. Is there a solution to this? Or should I consider purchasing a programmer for this type of PIC? If so, see if you can advise me.

I am attaching a screenshot of the error.

Thanks.
 

Attachments

  • Captura de pantalla 2024-10-15 232251.png
    Captura de pantalla 2024-10-15 232251.png
    79.4 KB · Views: 53
Do you have enough money for an XGecu TL866II ? I find this cheap programmer one of the best.. It can do Soooo many devices, You can get them for as little as £30..

As for the K150.. Seeing as the pic18F2520 is on the list just select that.. Its the same chip.
The error you see is an EEprom error.. Can you dissable the writing to eeprom?
 
Hi, I have found the list of PICs that the K150 supports, but the list of PICF18XXX does not appear, I do not understand why the K150 software has it as selectable. I have disabled Eprom writing and it does not work. Well, thanks for the answer. Regards.
 
The K150 is a pic16f628.. there may be a firmware update..

 
Hello,
Well I have already managed to program the PIC18F4520 with the PICKIT3, I decided on this PIC because its pins correspond to the PIC I was using, the PIC16F877A, my surprise was that the UART does not work with my NEXTION screen, in the simulation in PIC SIMULATOR IDE the UART works fine. I have not modified delays, I do not know if I have to have any previous configuration with this PIC18F4520, since it is the first time I use this PIC, I have carried out code tests to verify that it is recorded correctly with the PICKIT3, but the UART has not been possible. I attach the files. Let's see if someone with more knowledge can help me.
Greetings.
 

Attachments

  • LOOP_CAT_v1_15102024_PIC18F4520.asm
    95.2 KB · Views: 44
  • LOOP_CAT_v1_15102024_PIC18F4520.bas
    9.7 KB · Views: 42
  • LOOP_CAT_v1_15102024_PIC18F4520.hex
    28.5 KB · Views: 41
Well, a few days ago I received a classic training card, the HL-K18, and it has the Pic18F4520. I have downloaded a program with a serial buffer to test the RS232 and it works perfectly.
 
I have used it with an external 10Mhz x 4PLL = 40Mhz crystal and the program you left seems to work.

#define CONFIG1L = 0x00
#define CONFIG1H = 0x06
#define CONFIG2L = 0x1E
#define CONFIG2H = 0x1E
#define CONFIG3L = 0x00
#define CONFIG3H = 0x83
#define CONFIG4L = 0x80
#define CONFIG4H = 0x00
#define CONFIG5L = 0x0F
#define CONFIG5H = 0xC0
#define CONFIG6L = 0x0F
#define CONFIG6H = 0xE0
#define CONFIG7L = 0x0F
#define CONFIG7H = 0x40


' LOOP-CAT ver4.0 - jaume tomàs 2024
' PIC18F4520
' PANTALLA NEXTION 028
AllDigital
Define SINGLE_DECIMAL_PLACES = 2
'Define SIMULATION_WAITMS_VALUE = 10 'Definim temps per simulació
Define CLOCK_FREQUENCY = 40
'Define STRING_MAX_LENGTH = 16
 
Last edited:
Thanks for the reply, after trying to get it to work with no success, I tried with a PIC18F4550 and it worked fine!, I understand that the PIC18F4520 is faulty...

greetings
 
Query about reading and writing internal Eprom.
If I have written 16 bits in memory from the first memory address, I understand that they would occupy 8 bits in address 0 and 8 bits in address 1, when reading address 0, how can I obtain the reading of addresses 0 and 1? In other software, the values of each address are automatically concatenated. Is there this possibility in PIC SIMULATOR IDE?

Thanks.
 
Hello, I have managed to write and read 16 bits in the internal eprom of the PIC, I attach the code that I have made, can it be simplified? or is there a better option? Thanks
 

Attachments

  • Proves Eprom.bas
    1.2 KB · Views: 41
Check this out to see if it helps you:

Main:
Dim data As Word
WriteWord_EEProm(0, 1024)
data = ReadWord_EEProm(0)
End
Function WriteWord_EEProm(address As Word, data As Word) As Byte
Write address, data.LB
WaitMs 5
Write address +1, data.HB
WaitMs 5
ReturnValue 0
End Function
Function ReadWord_EEProm(address As Word) As Word
Symbol _Return = ReadWord_EEProm
Read address, _Return.LB
WaitMs 1
Read address +1, _Return.HB
WaitMs 1
End Function

I wrote these libraries to store variables ages ago, take a look to see if they might be useful to you.
 

Attachments

  • _FuncionesEEPROM.bas
    3.9 KB · Views: 37
Last edited:
OK thanks, I'll study it.

I have followed your posts with different forums and this topic I think I saw with a forum signed by you in 2013. ha ha ha

Comrade you are very level,

thank you
 
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
 

Attachments

  • LOOP_CAT_Calibrador.asm
    11.5 KB · Views: 29
  • LOOP_CAT_Calibrador.bas
    3.2 KB · Views: 30
  • LOOP_CAT_Calibrador.hex
    2.2 KB · Views: 28

Latest threads

New Articles From Microcontroller Tips

Back
Top