Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] How to handle PCINT8-11 on ATMEGA644P

2010-04-10 by erikc

Àíòîùåíêîâ Ðîìàí Âèêòîðîâè÷ wrote:
> Hello!
> I build project on AVRStudio 4.16 and WinAVR.
> I try handle  high level on PCINT8-11.
> 
> PORTB=0x00;
> DDRB=0xF0;
> 
> EICRA=0x02;
> EIMSK=0x01;
> EIFR=0x01;
> PCMSK1=0x0F;
> PCICR=0x02;
> PCIFR=0x02;
> 
> ISR(PCINT1_vect)
> {
>   unsigned char x = PORTB;
>   if ((x & Bit(0)) == 1)
>   {
>      ...
>   }
>   if ((x & Bit(1)) == 1)
>   {
>     ...
>   }
>   if ((x & Bit(2)) == 1)
>   {
>     ...
>   }
>   if ((x & Bit(3)) == 0)
>   {
>      ...
>   }
> }
> 
> It doesn't work.
> Any idea?
> 


Fix your code like this:



  ISR(PCINT1_vect)
  {
    unsigned char x = PORTB;
    if (x & Bit(0))
    {
       ...
    }
    if (x & Bit(1))
    {
      ...
    }
    if (x & Bit(2))
    {
      ...
    }
    if (x & Bit(3))
    {
       ...
    }
  } /* ISR */

Should work.

erikc

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.