c - How to enable more than one interrupt AVR -


i using atmega88pa pin changes on 2 pins. use pcint0 , pcint2 although have lot of other pins open if need use different pin. have been messing around things , able pcint0 work properly, problem came when trying pcint2 work.

if define , set pcint2 same way did pcint0 work nothing happens. have tried in new program see if else interfering in way did not solve anything. got rid of pcint0 see if pcint2 work on own still not able to.

here code had pcint0

ddrc = 0x20; // portc,5 output    sbi(portc,5);    usart_init(51);    lcd_init(lcd_disp_on);    lcd_clrscr();  pcicr |= (1 << pcie0); pcmsk0 |= (1 << pcint0); 

if change pcmsk2 , pcint2 nothing happens when trigger pin. here link data sheet atmega88pa datasheet

i think problem might largely due confusing names of various register flags. if stare @ datasheet long enough, you'll notice pcie2 , pcmsk2 not control pcint2. control pcint16 pcint23.

pcint0-pcint7 (which includes pcint2, want) controlled pcie0 in pcicr (which set) , pcmsk0 (not pcmsk2 mention in last comment.)

so, fix problem, need change last line to:

pcmsk0 |=(1 << pcint0) | (1 << pcint2)

disclaimer: have not had chance test on real hardware. please double-check datasheet.

hope helps.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -