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.
PIC Mask and acknowledge
Re:PIC Mask and acknowledge
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 < /*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;
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 < /*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;