ARM Technical Support Knowledge Articles

NO ISPI FLAG WHILE WORKING WITH SPI

Applies to: uVision Debugger

Answer


Information in this article applies to:


QUESTION

I'm using the SPI on the ADuC812, and what I've noted is that when I write a character to SPIDAT SFR, I never get the ISPI interrupt flag set in both SPI window and Interrupt System window when debugging, but the interrupt is vectored and executed. Is it a problem with the simulator?

Here's my test code.:

#include <aduc812.h>
#include <intrins.h>

static unsigned char number_of_ints;

void spi_data_send ( unsigned char character )    {

SPIDAT= character;         // MOV SPIDAT,#XXX
}


void SPI_int ( void )  interrupt 7   {
number_of_ints++;
_nop_();
}


void main ( void )   {

unsigned char i;

SPICON = 0x34;             // FOSC/4 Master mode SPI enabled
IE2 |=0x01;                // Enable SPI interrupt
EA = 1;

for ( i=0; i<=10; i++ )
      spi_data_send(i);
while(1);
}

ANSWER

It's not actually a problem. The interrupt bit is not set, but the interrupt routine is executed. It happens because the interrupt was programmed with auto-reset on interrupt entry described in the errata sheet.

In the example, the SPI interrupt is set immediately after the MOV SPIDAT,#XXX instruction which causes the PC to vector to the interrupt routine which then automatically clears the interrupt bit. The interrupt bit is set only for 2 cycles which are needed to fetch the interrupt vector. But since the instruction simulator simulates this fetch together with the previous instruction, you can't see the interrupt getting set and cleared but the interrupt routine is executed.

Everything works as it should. To test if the interrupt bit is being set, simply disable this interrupt and the interrupt request bit will be set after the MOV SPIDAT,#XXX instruction.

The auto-reset feature isn't described in the data sheet but in an errata sheet.

Article last edited on: 2004-11-03 15:02:08

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential