milesguidon
Member level 2
- Joined
- Dec 4, 2010
- Messages
- 52
- Helped
- 8
- Reputation
- 16
- Reaction score
- 8
- Trophy points
- 1,288
- Location
- Los Angeles, CA
- Activity points
- 1,753
Hi,
I think I'm seeing my microcontroller behave in an unpredictable way, and I know I'm wrong because computers usually have a good reason to do what they're doing...but I still can't figure it out.
I have configured the PIC18F to interrupt on a logic transition at pin RB5. It does work, and inside the ISR I can perform logic tests such as "if PORTBbits.RB5==1, do this" and "if PORTBbits.RB5==0, do this". I have a logic analyzer and I am seeing everything clearly as far as logic transitions and indications that my routines are taking place successfully (I usually use a dedicated LED, and insert blink() commands to see if something has happened predictably or not).
My problem right now is in my ISR--I am incrementing a counter every time there is a low-to-high or a high-to-low transition, so every time the ISR runs, the counter is incremented. In my main routine, I have a blink() command set to execute every time the counter reaches a value of 20. When the counter reaches 20, there's a blip on the logic analyzer, and the counter resets. My problem is that *this blip happens after only FOURTEEN low-to-high or high-to-low transitions*, as I count them by sight on the logic analyzer!! The logic transitions on the input pin are clear as day--it's a SMPTE timecode signal, which is something like a Manchester encoded signal at 2.4kHz.
I am thinking that there is some sort of odd condition that is causing the interrupt on change to interrupt twice while the input is high, but my logic input is coming from a comparator output with a 3kohm pull-up resistor.
Does this problem sound familiar to anybody? Thanks!
I think I'm seeing my microcontroller behave in an unpredictable way, and I know I'm wrong because computers usually have a good reason to do what they're doing...but I still can't figure it out.
I have configured the PIC18F to interrupt on a logic transition at pin RB5. It does work, and inside the ISR I can perform logic tests such as "if PORTBbits.RB5==1, do this" and "if PORTBbits.RB5==0, do this". I have a logic analyzer and I am seeing everything clearly as far as logic transitions and indications that my routines are taking place successfully (I usually use a dedicated LED, and insert blink() commands to see if something has happened predictably or not).
My problem right now is in my ISR--I am incrementing a counter every time there is a low-to-high or a high-to-low transition, so every time the ISR runs, the counter is incremented. In my main routine, I have a blink() command set to execute every time the counter reaches a value of 20. When the counter reaches 20, there's a blip on the logic analyzer, and the counter resets. My problem is that *this blip happens after only FOURTEEN low-to-high or high-to-low transitions*, as I count them by sight on the logic analyzer!! The logic transitions on the input pin are clear as day--it's a SMPTE timecode signal, which is something like a Manchester encoded signal at 2.4kHz.
I am thinking that there is some sort of odd condition that is causing the interrupt on change to interrupt twice while the input is high, but my logic input is coming from a comparator output with a 3kohm pull-up resistor.
Does this problem sound familiar to anybody? Thanks!