SPI Talk conseqcutive check how to:

Status
Not open for further replies.

Bastiaan

Well-known member
Hi as I am partially dividing the technical problems with my program I would like to ask for some advice: I dont know if this is common to do, but ill ask anyway a bother you a bit with trivial (more) questions

as i have this tftscreen Hx8357 as in the previous posts, with many other questions.
I would like to put the focus on timing and writing to the TFTscreen().

I have in total 4 thermocouples that are accessed, if put on max speed and without delay at around 3ms.
however the screen freezes over if run together with the other programs. therefore I would like to make a check on the interval of the CS pins, what would be the best approach in doing so?

timing_idea.png


the menuCheck (encoder and push button update) requires to update 20ms or (as fast as possible), and is parallel run in the if statements of the TFTScreen

what would be the best approach in timing and get a fluent output to the screen

Code:
unsigned long Interval=1000;
unsigned long nowMillis;//important

unsigned long ADCpreviousMillis=0; // ADC interval
unsigned long ADCInterval=1000;

unsigned long MenupreviousMillis=0; // Pushbutton and Encoder interval
unsigned long MenuInterval=20;

unsigned long ScreenpreviousMillis=0;// controls the interval over Screen TFTscreen function
unsigned long ScreenInterval=500;

unsigned long TC_previousMillis=0;// controls the interval over the total Function over the Thermocouple1-4
unsigned long TC_Interval=500;// controls the interval over the total Function over the Thermocouple1-4

unsigned long TC_1b1_previousMillis=0; //controls the interval between the thermocouple1-4 readings
unsigned long TC_1b1_Interval=100;//controls the interval between the thermocouple1-4 readings

Code:
 //give return value from function to pointer
   unsigned long ScreencurrentMillis=millis();
      if(ScreencurrentMillis-ScreenpreviousMillis>=ScreenInterval)
      {
        ScreenpreviousMillis=ScreencurrentMillis;
         
            TFTscreen(pArray_From_TC);
         
      } 
  
unsigned long ADCcurrentMillis=millis();
 if(ADCcurrentMillis-ADCpreviousMillis>=ADCInterval)
 {
  ADCpreviousMillis=ADCcurrentMillis;
  InternalADC();
 
 
 }
   
  unsigned long MenucurrentMillis=millis();
      if(MenucurrentMillis-MenupreviousMillis>=MenuInterval)
      {
        MenupreviousMillis=MenucurrentMillis;
         Menu1Check();
      }
       
   

        unsigned long TC_currentMillis=millis();
      if(TC_currentMillis-TC_previousMillis>=TC_Interval)
      {
       TC_previousMillis=TC_currentMillis;
       pArray_From_TC=Thermocouples1_4();
      }

many thanks for your time
 
Sorry it is hard to answer questions like this. As it is difficult to know what your actual issue is.

For example what does this actually mean?
however the screen freezes over if run together with the other programs
Are you saying that ice crystals form on the outside of the display? ;) Just sort of kidding.

But again are you saying that the screen stops updating? Or the screen stops responding to touch? But the rest of the program continues to run? Or are you saying that the code hangs or crashes some place? My guess is probably the later, unless for example you told the display code to update Asynchronous and you end up with two SPI conversations going on at the same time. Or likewise you start up an SPI transaction in an Interrupt, while some other SPI code is running in the main loop.

More later if needed, but first back to the other threads on this issue.
 
Status
Not open for further replies.
Back
Top