VMLAB users forum
General discussion boards >> Bug Reports >> PCInt error in ATMega168b

Message started by bitmaster on 07/22/11 at 18:50:34

Title: PCInt error in ATMega168b
Post by bitmaster on 07/22/11 at 18:50:34


first of all: very best Thanks to ThVortex for his really great work!!! I've downloaded his useravr-0.6.1.zip and it works fine, but I've found a small bug:
if You're using the PCInts You might get trouble in certain configurations, because there is a small mistake in the file 'ATmega168b.ini'. In section [Mask_register:PCICR] the register Bit_interrupts, Bit 1 should be IOCH1 instead of IOCH2. It seems to be a copy and paste error...
I've encountered a second problem without a solution: if I change a portbit within the PCInt service routine and delete the corresponding PCIFR bit afterwards, the PCInt service routine will be entered a second time (not in original VMLab!) even if there is no reason seen in the PCIFR. If I mask the portbit before changes in PCMSKn and release it after changes in PCMSKn, the service routine is entered only once (correct).

Title: Re: PCInt error in ATMega168b
Post by ThVortex on 07/25/11 at 02:54:03

The problem you have with PCIFR is the same thing that someone else found with the timer flag registers. The only workaround I can do for it is to move those registers into a separate component where I have more control over them instead of relying on VMLAB's builtin handling of the flag registers.

Title: Re: PCInt error in ATMega168b
Post by moderator on 07/26/11 at 08:37:31


I'll try to fix it, but unfortunately I do not have so much time now....

But allow me to understand the bug: the problem is in the SET_INTERRUPT_FLAG(...) function, that does not clear the interrupt properly when is set to zero, isn't it?

Title: Re: PCInt error in ATMega168b
Post by bitmaster on 07/26/11 at 11:58:43

my software is nearly final now, so I've done a lot of debugging with more studies.
I change some portbits (change direction of ports C and D and additional the value for the new output ports that change the PINC and D) within the pcint service routines (PCINT1 and 2). Then I can see the corresponding flags in PCIFR1/2 (PCIFR=00000110) that will be cleared in the next step by software. If I clear manually in VMLAB, PCIFR1 is cleared when I doubleclick PCIFR2 and vice versa (another bug or the reason for all that trouble??)!! So I can see the cleared PCIFR anyway but after the RETI the PCINT1 will be executed even the PCIFR is shown as 0 for both pcints.
The second experiment is:
if I unmask ("disable") the pcint1 via PCMSK1 in my service routine before I change PORTC (PCMSK2 still active, PORTD will be changed) and if I clear the PCIFR before RETI than PCINT2 will be entered (endless because PORTD is changed everytime...). So the PCMSKn works fine but the PCIFR is strange...

Thanks sooo much and allways keep in mind You do a great job and helps a lot of developers with this pretty perfect tool!!

To save You time I'll attach a short assembler program for testing.

VMLAB users forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.