attached the code, I hope somebody can see what's wrong!! thank you. ---- From: myke predko To: PICLIST@MITVMA.MIT.EDU Date: 16 May 1997 6:45 AM Subject: Re: TMR0 interrupt (PIC16c84 and PWM) >Osama wrote: >>the *ACTUAL* code is at the uni (closed Thursdays and Fridays :( ) i'll >>get it on Saturday and post it... >> >>it does run on the simulator. (this is what puzzles me most! shouldn't >>MPSIM be fully compatible with the real thing?) > >What I mean to say there are a lot of cases where the simulator seems to >indicate that something is working, but when you get out into the real >world, it upchucks. > >Last year, I spent about three weeks trying to nail down a problem that >worked fine in the simulator, but when I actually tried it out on hardware, >the device just sat there and did nothing. I finally traced the problem to >how I was simulating it, I had a delay routine that I skipped over in the >simulator because it took about an hour and a half to run (it delayed the >PIC for about 3 seconds). > >The problem ended up being that the interrupt routine that I was debugging >was active during this delay, but needed variables which were initialized >*after* the delay routine. It worked fine when the delay routine was >skipped and the interrupt didn't happen until after the variables were >initialized, but wouldn't work at all when the delay routine was working. > >It didn't matter how hard I stared at it - it worked fine in the simulator >and wouldn't work in the device. Maybe this is a case that would be >immediately obvious if you had an emulator. > > >Just reviewing this and realizing there is one MAJOR difference between >MPSIM (and MPLAB-SIM) and a real PIC. That's in how the registers come up >initialized. In both simulators, they are initialized to 0x000 and in the >PIC, they can be anything. > >I just went back to your original note and I'm thinking that this is >probably your problem. In the code you wrote, you didn't show how the PWM >variables were initialized. I suspect that you probably don't initialize >PWMCounter (because it shows up as 0x000 in the simulator) and when you run >your code it's actually greater than the test values (and nothing ever gets >output). > > >Just a question for everybody who's used a PIC emulator more than I have >(because I didn't think to look for this when I was lent a PICMaster), what >do the Register Values initialize to? > > >When you get the code, we should be able to find the problem, > >myke >> >>thanks. >> ---- >>From: myke predko >>To: PICLIST@MITVMA.MIT.EDU >>Date: 15 May 1997 23:46 PM >>Subject: Re: TMR0 interrupt (PIC16c84 and PWM) >> >>>Osama, >>> >>>Could you please post the *actual* code? I find that little problems in >>>assembler that screw up the whole program can be stared at for hours by >>the >>>author without seeing them. >>> >>>As well, have you run your code through the simulator (my first line of >>>defense/verification before I burn a part)? >>> >>>myke >> >> > >"My ancestors didn't spend millions of years clawing their way to the top of >the food chain, just so I could become a vegetarian" > Content-Type: application/octet-stream; name="Pwm.asm" Content-Disposition: attachment; filename="Pwm.asm" Attachment converted: wonderland:Pwm.asm (????/----) (00002DF8)