Maker Pro
Maker Pro

Atmel SPI interrupts not working

S

Stephen Inkpen

Jan 1, 1970
0
Here is my code:

SIGNAL(SIG_SPI)
{
spiTransferComplete = TRUE;
puts("int\r\n");
}

// set SS (PB4) as output
sbi(PORTB, 7);
sbi(DDRB, 7);
cbi(DDRB, 6);
sbi(DDRB, 5);
sbi(DDRB, 4); // SS must be output for Master mode to work

outp((1<<MSTR) | (1<<SPE) | (1<<SPR0), SPCR);

// clear status register
inp(SPSR);
spiTransferComplete = TRUE;

// enable SPI interrupt
sbi(SPCR, SPIE);

sei();

Is there any reason why my interrupt isn't getting fired when I call:

outp(data, SPDR);

Thanks,

Stephen Inkpen
Email Code: EA701JXZ2
 
T

Tim Wescott

Jan 1, 1970
0
This is almost certainly a case of not having the correct "screw the
processor bit" set to the correct state. Manufacturers of microcontrollers
like to have these little guys in their products to make life more
interesting for you and for me.

I'm not familiar with that exact microcontroller, but you might want to look
to see if there's any other bits you need to enable to make interrupts in
general work. It's not uncommon to have to set up the port to do the
interrupt in the first place, then set up the interrupt controller to pay
attention, then possible to have to set up the interrupt controller to
accept interrupts at all.

I would look for at least two, and as many as four different bits that you
need to set correctly to get your interrupts to work.
 
Top