For users of the Atmel AT91SAM7 and AT91SAM9 ARM CPU chips. Atmel has taken a new direction by combining on chip flash and ram with the ARM CPU on a single die. This provides low cost devices for small systems using the ARM CPU.
This group is to exchange information to help users get started and learn how to use the devices.
[at91sam7x256] Problem with connecting serial FLASH using SPI - dawido85 - Aug 19 11:16:35 2008
Hi, I'm trying to read JEDEC from my serial FLASH, but I keep getting
wrong id. I tested LLB and MISO/MOSI hard loop, both get me proper
data. Can somebody enlight me where I'm making mistake? This is my
code:
PMC_EnablePeripheral(AT91C_ID_PIOA); //turn on PIOA
peripheral
PIO_Configure(spi_pins, PIO_LISTSIZE(spi_pins)); //conf
MISO,MOSI,SPCK,NPCS
PMC_EnablePeripheral(AT91C_ID_SPI0); //turn on SPI0
//conf SPI: master mode, mode fault disabled, PS_FIXED and set PCS,
DLYBCS
SPI_Configure(AT91C_BASE_SPI0,AT91C_ID_SPI0,AT91C_SPI_MSTR |
AT91C_SPI_MODFDIS|
AT91C_SPI_PS_FIXED|
AT91C_SPI_PCS|
AT91C_SPI_DLYBCS);
//conf NPCS: CPHA=1, CSAAT=1, SCBR=0x30 for 1MHz, DLYBS, DLYBCT
SPI_ConfigureNPCS(AT91C_BASE_SPI0,0,
AT91C_SPI_NCPHA|
AT91C_SPI_CSAAT|
AT91C_SPI_SCBR|
AT91C_SPI_DLYBS|
AT91C_SPI_DLYBCT);
while(1)
{
SPI_Enable(AT91C_BASE_SPI0); //enable SPI
//send data to SPI0, PCS=0, data=0x9F -> get JEDEC ID
SPI_Write(AT91C_BASE_SPI0,0,0x9F);
/* Send data
//wait for tx to be empty
while ((spi->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
spi->SPI_TDR = data | AT91C_SPI_PCS;
//wait for tx end
while ((spi->SPI_SR & AT91C_SPI_ENDTX) == 0);*/
//read manufact byte
spi_buff[0]=SPI_Read(AT91C_BASE_SPI0);
/*Read data
//data have been recived?
while ((spi->SPI_SR & AT91C_SPI_RDRF) == 0);
return spi->SPI_RDR & 0xFFFF;*/
//write dummy byte
SPI_Write(AT91C_BASE_SPI0,0,0);
//get device id part 1
spi_buff[1]=SPI_Read(AT91C_BASE_SPI0);
//write dummy byte
SPI_Write(AT91C_BASE_SPI0,0,0);
//get device id part 2
spi_buff[2]=SPI_Read(AT91C_BASE_SPI0);
SPI_Disable(AT91C_BASE_SPI0); //disable SPI
}
}
I get 0x0028F1FF instead of 0x003016EF. ;/
------------------------------------

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )
RE: [at91sam7x256] Problem with connecting serial FLASH using SPI - hlow - Aug 19 11:30:57 2008
Which mode SPI mode is your serial FLASH ?
Mode 0,1,2,or 3?
(http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus).
Look like you are using Mode 1.
You have to configure your NPCS to the right mode to the serial flash.
_____
From: A...@yahoogroups.com [mailto:A...@yahoogroups.com] On Behalf Of
dawido85
Sent: 19 August 2008 16:17
To: A...@yahoogroups.com
Subject: [AT91SAM] [at91sam7x256] Problem with connecting serial FLASH using
SPI
Hi, I'm trying to read JEDEC from my serial FLASH, but I keep getting
wrong id. I tested LLB and MISO/MOSI hard loop, both get me proper
data. Can somebody enlight me where I'm making mistake? This is my
code:
PMC_EnablePeripheral(AT91C_ID_PIOA); //turn on PIOA
peripheral
PIO_Configure(spi_pins, PIO_LISTSIZE(spi_pins)); //conf
MISO,MOSI,SPCK,NPCS
PMC_EnablePeripheral(AT91C_ID_SPI0); //turn on SPI0
//conf SPI: master mode, mode fault disabled, PS_FIXED and set PCS,
DLYBCS
SPI_Configure(AT91C_BASE_SPI0,AT91C_ID_SPI0,AT91C_SPI_MSTR |
AT91C_SPI_MODFDIS|
AT91C_SPI_PS_FIXED|
AT91C_SPI_PCS|
AT91C_SPI_DLYBCS);
//conf NPCS: CPHA=1, CSAAT=1, SCBR=0x30 for 1MHz, DLYBS, DLYBCT
SPI_ConfigureNPCS(AT91C_BASE_SPI0,0,
AT91C_SPI_NCPHA|
AT91C_SPI_CSAAT|
AT91C_SPI_SCBR|
AT91C_SPI_DLYBS|
AT91C_SPI_DLYBCT);
while(1)
{
SPI_Enable(AT91C_BASE_SPI0); //enable SPI
//send data to SPI0, PCS=0, data=0x9F -> get JEDEC ID
SPI_Write(AT91C_BASE_SPI0,0,0x9F);
/* Send data
//wait for tx to be empty
while ((spi->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
spi->SPI_TDR = data | AT91C_SPI_PCS;
//wait for tx end
while ((spi->SPI_SR & AT91C_SPI_ENDTX) == 0);*/
//read manufact byte
spi_buff[0]=SPI_Read(AT91C_BASE_SPI0);
/*Read data
//data have been recived?
while ((spi->SPI_SR & AT91C_SPI_RDRF) == 0);
return spi->SPI_RDR & 0xFFFF;*/
//write dummy byte
SPI_Write(AT91C_BASE_SPI0,0,0);
//get device id part 1
spi_buff[1]=SPI_Read(AT91C_BASE_SPI0);
//write dummy byte
SPI_Write(AT91C_BASE_SPI0,0,0);
//get device id part 2
spi_buff[2]=SPI_Read(AT91C_BASE_SPI0);
SPI_Disable(AT91C_BASE_SPI0); //disable SPI
}
}
I get 0x0028F1FF instead of 0x003016EF. ;/

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )
Re: [at91sam7x256] Problem with connecting serial FLASH using SPI - dawido85 - Aug 19 13:12:42 2008
According to atmel:
http://support.atmel.no/bin/customer?=&action=viewKbEntry&id=196
I'm setting NCPHA=1 -> CPHA=0 and it's mode 0. Sorry for typo in my
previous post. My serial FLASH operate with mode 0 or 3, so I guess
mode config is ok.
Thanks for reply.
--- In A...@yahoogroups.com, "hlow"
wrote:
>
> Which mode SPI mode is your serial FLASH ?
>
> Mode 0,1,2,or 3?
>
>
>
> (http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus).
>
>
>
> Look like you are using Mode 1.
>
> You have to configure your NPCS to the right mode to the serial
flash.
>
>
>
>
>
> _____
>
> From: A...@yahoogroups.com [mailto:A...@yahoogroups.com] On
Behalf Of
> dawido85
> Sent: 19 August 2008 16:17
> To: A...@yahoogroups.com
> Subject: [AT91SAM] [at91sam7x256] Problem with connecting serial
FLASH using
> SPI
>
>
>
> Hi, I'm trying to read JEDEC from my serial FLASH, but I keep
getting
> wrong id. I tested LLB and MISO/MOSI hard loop, both get me proper
> data. Can somebody enlight me where I'm making mistake? This is my
> code:
>
> PMC_EnablePeripheral(AT91C_ID_PIOA); //turn on PIOA
> peripheral
> PIO_Configure(spi_pins, PIO_LISTSIZE(spi_pins)); //conf
> MISO,MOSI,SPCK,NPCS
> PMC_EnablePeripheral(AT91C_ID_SPI0); //turn on SPI0
>
> //conf SPI: master mode, mode fault disabled, PS_FIXED and set PCS,
> DLYBCS
> SPI_Configure(AT91C_BASE_SPI0,AT91C_ID_SPI0,AT91C_SPI_MSTR |
> AT91C_SPI_MODFDIS|
> AT91C_SPI_PS_FIXED|
> AT91C_SPI_PCS|
> AT91C_SPI_DLYBCS);
>
> //conf NPCS: CPHA=1, CSAAT=1, SCBR=0x30 for 1MHz, DLYBS, DLYBCT
> SPI_ConfigureNPCS(AT91C_BASE_SPI0,0,
> AT91C_SPI_NCPHA|
> AT91C_SPI_CSAAT|
> AT91C_SPI_SCBR|
> AT91C_SPI_DLYBS|
> AT91C_SPI_DLYBCT);
> while(1)
> {
>
> SPI_Enable(AT91C_BASE_SPI0); //enable SPI
>
> //send data to SPI0, PCS=0, data=0x9F -> get JEDEC ID
> SPI_Write(AT91C_BASE_SPI0,0,0x9F);
>
> /* Send data
> //wait for tx to be empty
> while ((spi->SPI_SR & AT91C_SPI_TXEMPTY) == 0);
> spi->SPI_TDR = data | AT91C_SPI_PCS;
> //wait for tx end
> while ((spi->SPI_SR & AT91C_SPI_ENDTX) == 0);*/
>
> //read manufact byte
> spi_buff[0]=SPI_Read(AT91C_BASE_SPI0);
>
> /*Read data
> //data have been recived?
> while ((spi->SPI_SR & AT91C_SPI_RDRF) == 0);
> return spi->SPI_RDR & 0xFFFF;*/
>
> //write dummy byte
> SPI_Write(AT91C_BASE_SPI0,0,0);
> //get device id part 1
> spi_buff[1]=SPI_Read(AT91C_BASE_SPI0);
>
> //write dummy byte
> SPI_Write(AT91C_BASE_SPI0,0,0);
> //get device id part 2
> spi_buff[2]=SPI_Read(AT91C_BASE_SPI0);
>
> SPI_Disable(AT91C_BASE_SPI0); //disable SPI
> }
> }
>
> I get 0x0028F1FF instead of 0x003016EF. ;/
>
------------------------------------

(You need to be a member of AT91SAM -- send a blank email to AT91SAM-subscribe@yahoogroups.com )