AMcTools Forum 
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
PCInt error in ATMega168b (Read 4270 times)
bitmaster
YaBB Newbies
*
Offline

I Love YaBB 2!

Posts: 2

PCInt error in ATMega168b
07/22/11 at 18:50:34
 
Hi,

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).
Back to top
 
 
  IP Logged
ThVortex
Global Moderator
*****
Offline



Posts: 160
Austin, TX, USA
Gender: male
Re: PCInt error in ATMega168b
Reply #1 - 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.

Back to top
 
 
WWW   IP Logged
moderator
YaBB Administrator
*****
Offline

I love forums, don't
you?

Posts: 308
AMcTools (Spain)
Gender: male
Re: PCInt error in ATMega168b
Reply #2 - 07/26/11 at 08:37:31
 
Hi,

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?

Back to top
 
 
WWW   IP Logged
bitmaster
YaBB Newbies
*
Offline

I Love YaBB 2!

Posts: 2

Re: PCInt error in ATMega168b
Reply #3 - 07/26/11 at 11:58:43
 
Hi,
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.

Back to top
 
  IP Logged
Pages: 1
Send Topic Print