Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. //measure rc time to charge to '1' on RC_READ pin
  2. uint32_t rctmr_get(uint8_t ch_pin) {
  3. uint32_t tmp;
  4. IO_IN(RC_DDR, ch_pin); //discharge. ch_pin idles high/input
  5. IO_OUT(RC_DDR, RC_READ); //discharges the capacitor (RC_READ idles low/output)
  6. while (IO_GET(RC_PORTIN, RC_READ)) continue; //until the capacitor is fully discharged
  7. IO_OUT(RC_PORT, ch_pin); //start to charge through the ch_pin
  8. IO_IN(RC_DDR, RC_READ); //start to charge up the capacitor
  9. tmp = ticks(); //time stamp tmp
  10. while (IO_GET(RC_PORTIN, RC_READ)==0) continue; //wait for READ pin to go high
  11. tmp = ticks() - tmp; //measure the time elapsed
  12. IO_OUT(RC_DDR, RC_READ); //discharge the capacitor
  13. IO_IN(RC_DDR, ch_pin); //start to discharge from the charge pin (idles high / input)
  14. return tmp;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement