EmbeddedRelated.com
Forums

at91sam7 Reset routine

Started by wuerzi July 23, 2008
I have some problems with the software reset on an Atmel at91sam7s256
Controller, in principle it should work but if I change things that
have absolutely no visible connection to the reset controller it stops
working. To be more exact either it starts normal and works after a
reset or it stops working after a view lines of main and the whole
controller hangs. An example I have a configuration if the CSAAT-bit
in the SPI Chip Select register is set my reset routine doesn't work
and if not set it works. In case of a prober hardware reset there is
never a problem so it must be some differences between hard and
software reset.
I'm using the gcc compiler.
My code:

void RAMFUNC DoReset() {

// Execute a software reset of the SPI
AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SWRST;
// Configure SPI in Master Mode with No CS selected !!!
AT91C_BASE_SPI->SPI_MR = (AT91C_SPI_MSTR | AT91C_SPI_MODFDIS |
AT91C_SPI_PCS);
// Fixed perpheral select, CS0
//SPI_BASE->SPI_MR = (AT91C_SPI_MSTR); // | AT91C_SPI_LLB); // Remove
LLB!
// Disable the PDC transfer
AT91C_BASE_SPI->SPI_PTCR = (AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS);
// Disable the SPI
AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SPIDIS;
// Disable the SPI clock
AT91C_BASE_PMC->PMC_PCDR = (1 << AT91C_ID_SPI);

DisableAllInts();

// Disable PMC devices
AT91C_BASE_PMC->PMC_SCDR = 0xFFFFFFFF;

//AT91S_RSTC->RSTC_RCR=1;
//AT91C_RSTC->//_RCR=1;
AT91C_BASE_RSTC->RSTC_RCR = 0xA5000003; // Controller+Periph
}

Best regards
Marcus