OK - I'm baffled ... what am I doing wrong here ?? - solved

Beta Testing discussion on mikroC PRO for AVR.
Post Reply
Author
Message
sadavis80
Posts: 114
Joined: 15 Nov 2008 19:27

OK - I'm baffled ... what am I doing wrong here ?? - solved

#1 Post by sadavis80 » 20 Nov 2008 21:47

In code - install interrupt from Timer1 (works just fine).
ISR - code...

void interrupt() org 0x22 { // compare match TIMER1A
PORTB7 = 1; // scope flag to tell me I'm IN routine
PORTC = 255; // initialized to ZERO on startup
PORTB7 = 0; // scope flag to tell me I'm leaving routine
}

Interrupts happening every ~40 usecs - all verified by PORTB7 on scope.
For reasons that I cannot yet fathom, PORTC goes high for ~ 6usecs and then goes back LOW on every interrupt.
Why does it not stay HIGH?? The .LST output looks like it's doing the right thing ...
AFAIK, PORTC is not addressed anywhere else in the program except startup. If I change initial setting to 0xFF (255), then all bits go high (and stay there) just as expected.

Shouldn't matter, but I'm using a BigAVR board with 10 MHz clock.

OK. I finally figured it out. I am actually using TWO timers set for the same frequency and I copy/pasted the code from the 1st to set up the second. Problem was that I also copied the line that enabled the INTERRUPT for the second one.. and I had NO ISR for that. I don't know EXACTLY what was happening - it should have just made a quick call and return ... well, I see that the addresses all default to JMP 0 instead of going to an RTI instruction. Anyway - it's now doing at least one or two things it's supposed to do :). I guess it was continually jumping back to MAIN on every (errant) interrupt and starting over - I would just get the desired one started first every time so I'd see it OK on the scope -- even at the desired interval somehow...

Steve

Post Reply

Return to “mikroC PRO for AVR Beta Testing”