View previous topic :: View next topic |
Author |
Message |
dahonig36 Guest
|
Timer ISRs can break RS232 |
Posted: Fri Sep 26, 2008 12:33 am |
|
|
I had to add pwm modulation to led drivers
that were not on the hardware pwm outputs on a
11Mhz 16F887. I first added PWM bit banging to
the control loop, but it flickered when processing commands.
I had used timer 1 for something but it was too
slow to pwm. When I tried to use timer 0 or 2,
by copying the ISR code (and renaming the functions)
I broke the RS 232 interface. Whether or not I
enabled the interrupts didn't matter. WTF?
I think it has to do with the way the CCS compiler handles
interrupts, when more than one ISR accesses a global
variable. When I gutted the second ISR of any code
it worked fine, and it worked fine when I removed the original
ISR. But more than one ISR messing with the same global
hosed my RS232!! Took me an afternoon to find this.
Still this compiler has saved so much effort its worth working with
despite its warts. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Sep 26, 2008 3:03 am |
|
|
Can you show a minimal code example that produces the problem? |
|
|
Ttelmah Guest
|
|
Posted: Sat Sep 27, 2008 2:29 am |
|
|
Agree. You need to post and example.
However there is nothing in the 'CCS compiler handles
interrupts', that will break the RS232. Things that may/will:
Interrupt handlers that take too long. This is the 'classic'...
Not having 'errors' in your RS232 declaration.
Having 'delay' statements in your interrupt handler.
A search here, will find lots (hundreds) of posts about how interrupt handling needs to be done to work reliably. The data that 'stripping' the handler down, makes it work, suggests that the first is the problem.
Best Wishes |
|
|
|