Community
cancel
Showing results for 
Search instead for 
Did you mean: 
ddor
Novice
936 Views

mcu api wakeups

hello again,

i'm trying to write a code for the MCU to be a "interrupt generator" for the cpp code i'm writing, which goes to S3 state for some time..

the general idea is that the cpp file does some work, registers a wake up with the MCU (using host_receive), goes to S3, and should be waken up by the MCU, which is set to sending a wakeup 20s after the wakeup called was registered with him.

the code for the MCU:

void mcu_main()

{

int len;

char buf[64];

while(1){

do {

len = host_receive((unsigned char *)buf, 64);

mcu_sleep(10);

} while (len <= 0);

if (strncmp(buf, "start", 5) == 0)

{

debug_print(DBG_INFO, "registered a wake up call in 20 secs!\n");

mcu_sleep(2000);

host_send((unsigned char*)"wake up!\n", 10);

}

}

}

the problem is, that i always get the wakeup call after 2.5 seconds, and not 20.. is there a reason that happens ?

thanks,

Dor

0 Kudos
1 Reply
idata
Community Manager
45 Views

Hi dorlX,

 

 

According to your description, the if statement is, at some point, true and the message "registered a wake up call in 20 secs!\n" is printed before the MCU goes to sleep. Have you tried to change the 2000 value to another one just to see if you get different times for the wakeup call?

 

 

Regards,

 

Diego
Reply