Hello!
I am working with PIC18F27K42 and Nextion display, the settings are as following,
Oscillator: 8Mhz with PLL
Channel: 2 (Tx:B6 and Rx:B7)
Baud: 57600
The problem I am facing is inconsistent working/starting/communication/initialization of the PIC and Nextion, I have noticed at few power ON of the circuit the communication between PIC and display fails and then nothing is displayed on the screen, if I press the reset button (MCLR) then the communication between both is correctly initialized and works absolutely fine, but at few power ON it do not start correctly I notice as if the initialization has gone wrong.
Can someone point out what could be the problem, or I am missing something (some delay before or after) One of the thoughts I am getting in my mind is after powering the circuit wait for a moment and somehow reset (MCLR) the PIC, as I see every time I press the reset button the display and PIC initialize perfect and works fine after that, but at few power ON I am facing this problem of both not getting initialization correctly.
Kindly correct me.
Thank you.
Abhi
UART Communication
Moderator: Benj
-
- Valued Contributor
- Posts: 696
- Joined: Fri Jun 06, 2014 3:53 pm
- Has thanked: 185 times
- Been thanked: 204 times
- Contact:
Re: UART Communication
Hi Abhi
Could it be your config? That chip has a Power Up Timer and default is 64mS. You can change in Project Options etc.
Hope this helps
Regards
Could it be your config? That chip has a Power Up Timer and default is 64mS. You can change in Project Options etc.
Hope this helps
Regards
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: UART Communication
Hi! Chipfryer
Thank you for your comments, indeed the timer was at its default value of 64mS, but I disabled that, I thought that was causing the problem, I am going to check that tomorrow morning and keep you posted.
Thank you again for your word.
Abhi
Thank you for your comments, indeed the timer was at its default value of 64mS, but I disabled that, I thought that was causing the problem, I am going to check that tomorrow morning and keep you posted.
Thank you again for your word.
Abhi
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: UART Communication
Hi! Chipfryer
Kindly excuse for the delayed reply, I was traveling to Mumbai (Bombay) last week.
For my surprise the communication between PIC and display works in both the conditions of Power Up Timer, but sometimes it miss, may be 2 times in 10 power ON cycles.
I am still trying on my development board for the moment, let me check the same in real hardware to conclude.
Abhi
Kindly excuse for the delayed reply, I was traveling to Mumbai (Bombay) last week.
For my surprise the communication between PIC and display works in both the conditions of Power Up Timer, but sometimes it miss, may be 2 times in 10 power ON cycles.
I am still trying on my development board for the moment, let me check the same in real hardware to conclude.
Abhi
- Bachman
- Posts: 116
- Joined: Sun Sep 07, 2014 11:37 am
- Location: Hungary
- Has thanked: 9 times
- Been thanked: 53 times
- Contact:
Re: UART Communication
Hi Abhi!
Try to add 250-300 ms delay before UART initialization. If you turn on the Nextion display, it's send out some data and it can make overflow condition in the PIC's receive side. Or, right after the UART initialization, try this C code:
U1 means UART1, modify it, if using other than UART1. I don't know, how Flowcode initializes UART module, maybe this help.
Try to add 250-300 ms delay before UART initialization. If you turn on the Nextion display, it's send out some data and it can make overflow condition in the PIC's receive side. Or, right after the UART initialization, try this C code:
Code: Select all
U1CON2bits.RUNOVF=1;
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: UART Communication
Hi! Bachman
good afternoon
Thank you for your feedback, I will try the method you suggested and also keep you posted.
Thank you again.
Abhi
good afternoon
Thank you for your feedback, I will try the method you suggested and also keep you posted.
Thank you again.
Abhi
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: UART Communication
Hello! Bachman
Your suggestion (300mS) solved the problem, now on every power ON communication between both is established successfully.
Thank you for your quick answer, cheers....
Abhi
Your suggestion (300mS) solved the problem, now on every power ON communication between both is established successfully.
Thank you for your quick answer, cheers....
Abhi
- Bachman
- Posts: 116
- Joined: Sun Sep 07, 2014 11:37 am
- Location: Hungary
- Has thanked: 9 times
- Been thanked: 53 times
- Contact:
Re: UART Communication
Looks like, i've mixed up the things... Well, the Nextion display needs around 250 - 300 ms after power up to initialize itself. Just an idea, you can use this time. In the display, create a "welcome" screen (logo, picture etc.) as the startup screen (page 0). Initialize the controller, after initialization done, wait 1-2 seconds and start with screen 2 in the Nextion.
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: UART Communication
Hi! Bachman
good morning
You speak my mind, exactly the same has been done with the opening screen and the following screens, now it works perfect.
Thank you, my friend.
Abhi
good morning
You speak my mind, exactly the same has been done with the opening screen and the following screens, now it works perfect.
Thank you, my friend.
Abhi