Separate delay for print on UART Screen without effecting other function   

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DeAa_335316
Level 4
Level 4
First like received

Hello,

   

I want to print all my value after 1 minute without interrupting or increasing delay for other function .

   

for Example i am showing  arduino code . it won't call PrintAllValue(); function till complete the one minute delay and won't effect or increase the delay for other function . 

   

   if((millis()- PrintDelay)>1000)
      {
        PrintDelay = millis();

   

         PrintAllValue();

   

       }

   

I write smiler way in cypress but it showing error ...

   

  if ((CyDelay()-PrintDelay)>1000))
         {
            PrintDelay=CyDelay(1000);

   

            PrintAllValue();
         }

   

 

   

 

   

Best Regards 

   

Deepak Aagri

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

CyDelay() uses a timed loop just "burning" CPU power. Not what you want. See description in "System Reference Guide".

   

You should set up a timer with an interrupt and maintain an internal counter yourself. Granularity may be as low as one millisecond

   

 

   

Bob

0 Likes

Thanks Bob..

   

would you like to share the sample code for that....?

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

You cannot convert that directly, since there is no corresponding millis() function. Your Ardiono example uses a function that returns a time value (milli seconds since startup), and uses that to find out how many time has passed. CyDelay() waits for the specified time, and has no return value - thats why you get a compile error.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

"would you like to share the sample code for that....?" Its not a sample code, it is a simple code.

   

extern volatile uint32 msCounter;

   

void TOnkHzHandler(void)

   

{

   

    msCounter++;

   

}
 

   

Have an interrupt connected to a 1 kHz clock

   

 

   

Bob

0 Likes