Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SPI based flash memory interface issue

Status
Not open for further replies.

engr.waqas

Full Member level 3
Joined
Jul 21, 2009
Messages
172
Helped
13
Reputation
26
Reaction score
10
Trophy points
1,298
Location
karachi,Pakistan
Activity points
2,342
I am using a SPI flash memory, AT25DF021, with PIC24FJ64GB004 microcontroller. I am using the following C30 SPI library code (OpenSPI1()) and configuration to initiate the SPI peripheral of MCU. I have remapped the correct MCU pins for SPI peripheral (using C30's PPS library). I later use putsSPI1() and getsSPI1() library functions to communicate with AT25DF021 but no proper data transmission and reception happens.


#define USE_AND_OR

// Mode-0, Master, 8-bit data
OpenSPI1(DISABLE_SCK_PIN | ENABLE_SDO_PIN | SPI_MODE8_ON | SPI_SMP_OFF | SPI_CKE_ON | SLAVE_ENABLE_OFF |
CLK_POL_ACTIVE_HIGH | MASTER_ENABLE_ON | SEC_PRESCAL_1_1 | PRI_PRESCAL_16_1, FRAME_ENABLE_OFF |
FRAME_SYNC_OUTPUT | FRAME_SYNC_ACTIVE_LOW | SPI_FRM_PULSE_PREV_CLK | SPI_ENH_BUFF_DISABLE,
SPI_ENABLE | SPI_IDLE_CON | SPI_RX_OVFLOW_CLR);


//........ Flash read code below

unsigned int NFWA[5];


MEMORY_CS=0; // memory chip select
NFWA[0]=0x03; // "Read Array" SPI command
NFWA[1]=0x00; // 3 address bytes (0x000000)
NFWA[2]=0x00;
NFWA[3]=0x00;

SPI1send(4, (unsigned int *)NFWA);

SPI1receive(2, (unsigned int *)NFWA, 40); // Reading 2 bytes in NFWA[]

MEMORY_CS=1;
// NFWA[0] has 0x0000 now


Please tell me whether I am using the correct SPI configuration for AT25DF021. Or, do you see any other problem.
 

First expect a warning from MODS because of posting code without a code tag;-):roll::evil:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top