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

PSoC™ 4

DeAa_335316
Level 4
First like received
Level 4

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
50 questions asked 10 questions asked 1000 solutions authored
Level 10

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
DeAa_335316
Level 4
First like received
Level 4

Thanks Bob..

   

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

0 Likes
HeLi_263931
Level 8
100 likes received 50 likes received 25 likes received
Level 8

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
50 questions asked 10 questions asked 1000 solutions authored
Level 10

"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