Guest User

Untitled

a guest
Jul 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. uint16_t divh1 = RTC->DIVH;
  2. uint16_t divl1 = RTC->DIVL;
  3. uint16_t cnth1 = RTC->CNTH;
  4. uint16_t cntl1 = RTC->CNTL;
  5.  
  6. uint16_t divh2 = RTC->DIVH;
  7. uint16_t divl2 = RTC->DIVL;
  8. uint16_t cnth2 = RTC->CNTH;
  9. uint16_t cntl2 = RTC->CNTL;
  10.  
  11. uint16_t divh, divl, cnth, cntl;
  12.  
  13. /* cntl is decrementing */
  14. if(cntl1 < cntl2) {
  15. /* overflow occurred between reads of cntl, hence it
  16. * couldn't have occurred before the first read. */
  17. divh = divh1;
  18. divl = divl1;
  19. cnth = cnth1;
  20. cntl = cntl1;
  21. } else {
  22. /* no overflow between reads of cntl, hence the
  23. * values between the reads are correct */
  24. divh = divh2;
  25. divl = divl2;
  26. cnth = cnth2;
  27. cntl = cntl2;
  28. }
Add Comment
Please, Sign In to add comment