CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Send and receive data from the Nextion serial display

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fabio2018



Joined: 07 Sep 2017
Posts: 3

View user's profile Send private message

Send and receive data from the Nextion serial display
PostPosted: Sun Jul 22, 2018 2:32 pm     Reply with quote

Hello people,
I have this code below that I want to use to receive data from the nextion, but I cant receive data when the button is triggered. When I send data does not work. Does not work the 2 together send and receive. Could someone give me a solution:

Code:

int conta;
int valor;

while(true) {
  d=getc();     //recebe dados do display nextion
  if(d==1020){
    printf(lcd_putc,"\acionada");
  }

  if (input(PIN_a3)){
     conta=conta+1;//envia dados da variavel conta para display nextion
     printf("n1.val=");
     printf("%u",valor);
     printf("ÿÿÿ");
    }

  if(input(PIN_a2)){
   conta=conta-1;
   printf("n1.val=");
   printf("%u",valor);
   printf("ÿÿÿ");
  }
}
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jul 22, 2018 3:01 pm     Reply with quote

We need to know a few things..
1) What PIC are you using ?
2) Is that display a 3 volt or 5 volt device ?

Odds are it's really a 3 volt device ( '1' and '0' on the data lines are 3 volt ). I seem to recall the signal lines are '5 volt tolerant' BUT signalling is 0, 3 volts.
If true then you should use a PIC that will run at 3 volts at the desired speed. That means choosing a PIC with an 'L' in the device, like 16LF1234 NOT a 16F1234. Be sure to check the electrical specs section of the datasheet ! There are some PICs that will work from 3 to 5 volts though.

Search the 'code library' as well as this forum for 'Nextion', you should get a few hits.

Also be sure your power supply has sufficient current to run the display ! Often overlooked it is important !

edit: I was curious(and don't want to go out in 90*F sun...), so I downloaded the datasheet for the 1st model.CONFIRMED that data lines( send, receive) ARE 3 volt logic levels.

Jay


Last edited by temtronic on Mon Jul 23, 2018 7:04 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Mon Jul 23, 2018 12:54 am     Reply with quote

Other things:

The displays specifically say they require a minimum of 5mSec before being sent data. This is also from the point when they wake, not the PIC. PIC's habitually start to wake before a lot of other chips. You need perhaps a 100mSec wait at the start of your code.
All commands need to be terminated by \xFF\xFF\xFF. You are using the "ÿÿÿ" sequence, which 'may' generate this, but this is dependant on your system character set. Unless you are sure this is generating the hex FF sequence better to use the hex escaped sequence.
You are sending the variable 'valor', but do not initialise it. It could contain anything....
Your commands put 'valor' into the variable 'n1' on the display. However nothing is written to the screen. You are not sending any command to physically display this.
You have no receive serial commands, so you are not going to receive anything from the display.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group