Rev 783 | Rev 790 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 783 | Rev 785 | ||
---|---|---|---|
Line 49... | Line 49... | ||
49 | } |
49 | } |
50 | else // PWM is low |
50 | else // PWM is low |
51 | { |
51 | { |
52 | if((PWMCount) && (PWMCount < 400)) |
52 | if((PWMCount) && (PWMCount < 400)) |
53 | { |
53 | { |
- | 54 | if(PWMCount <9) PWMHeading = 0; |
|
54 | PWMHeading = (((uint32_t)PWMCount * 1024L) / 1000L) - 10; // correct timebase and offset |
55 | else PWMHeading = ((uint32_t)(PWMCount - 9) * 1049L) >> 10; // correct timebase and offset |
55 | PWMTimeout = 12; // if 12 periodes long no valid PWM was detected the data are invalid |
56 | PWMTimeout = 12; // if 12 periodes long no valid PWM was detected the data are invalid |
56 | // 12 * 400 counts * 102.4 us = 419 ms |
57 | // 12 * 400 counts * 102.4 us = 419 ms |
57 | } |
58 | } |
58 | PWMCount = 0; // reset pwm counter |
59 | PWMCount = 0; // reset pwm counter |
59 | } |
60 | } |