PIC Mask and acknowledge

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
DarylD

PIC Mask and acknowledge

Post by DarylD »

I think I may have a ickle bug in my PIC mask and acknowledge code.

Basically, could I have a sneaky-peak at others implementations to compare.

Thanks.

Daryl.
Slasher

Re:PIC Mask and acknowledge

Post by Slasher »

I know what you mean. Initially mine worked, i had a master and slave mask for both master and slave pic.
I was saving the states in the inverse bits ie the way the pic excepts them, 0 - irq line enabled or 1 - irq line disabled.
but this was causing problems after i call the funtion to enable an irq level, say level 1. If call it again to enable say level 0, the system goes off the WALL.
so this is how i did it,

unsigned char master_mask,slave_mask;

void set_level(unsigned char level) /*levels from 0 to 15*/
{
if (level >=0 && level < 8) /*master pic*/
{
master=master|level;
mask_pic_master(~master);
}
else
if(level >= 8 && level <16)/* slave pic*/
{
level=level - 8;
slave=slave|level;
mask_pic_slave(~slave);
}
return;
}

the masks are stored in absolute form but inverted when sent to the pic.
Hope this helps;
Post Reply