This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Trying to write/read to the NOR Flash S29GL128P using EMIF but can only read 0xFFFF instead of the actual data that was written, here are my steps
int main(void)
{
/* USER CODE BEGIN (3) */
_enable_IRQ_interrupt_();
_mpuInit_();
_mpuEnable_();
emif_ASYNC1Init();
uint16_t *base_addr = (uint16_t *) 0x60000000;
uint16_t data1 = 0x1234;
uint16_t Read_back_data = 1947;
*((uint16_t *) base_addr + 0x555) = 0x00AA; /* write unlock cycle 1 */
*((uint16_t *) base_addr + 0x2AA) = 0x0055; /* write unlock cycle 2 */
*((uint16_t *) base_addr + 0x555) = 0x00A0; /* write program setup command */
*((uint16_t *) 0x60000000) = data1; /* write data to be programmed */
__delay_cycles(150000);
Read_back_data = *((uint16_t *) 0x60000000);
/* USER CODE END */
return 0;
}
Questions:
Many thanks in advance!
Hi Rachana,
For interfacing NOR flash, is 8-bit mode or 16-bit mode used?
If 16-bit mode is used, the EMIF BA[1] should be mapped to NOR Addr[0]
For 8-bit interface mode, the EMIF BA[1:0] should be connected to NOR Addr[1:0]
Where to access these DQ pins in the user space?
DQ[x] is data pin of NOR flash. EMIF doesn't have DQ pin, but it has DQM pin which byte enable pin.
Can you try this:
*( (uint16_t *)base_addr + 0xAAA ) = 0x00AA; /* write unlock cycle 1 */
*( (uint16_t *)base_addr + 0x554 ) = 0x0055; /* write unlock cycle 2 */
*( (uint16_t *)base_addr + 0xAAA) = 0x00A0; /* write program setup command */
Hi QJ,
16-bit mode is used and yes, the EMIF BA[1] is mapped to NOR Addr[0]. I have double checked this on the board.
Ah yes, I meant the EMIF_DATA[x] pin on the TMS570 wihch is mapped to the DQ[x] pin on the NOR flash.
I have updated with the lines you suggested, still the Read_back_data reads as 0xFFFF.
Are there any further steps to be performed after the following line:
*((uint16_t *) 0x60000000) = data1; /* write data to be programmed */
Also, could you please confirm if the line added to the linker file HL_sys_link.c is sufficient?
HI Rachana,
Please try my code. I developed this code years ago, and tested on TMS570 board.
Hi Wang, thanks for the code. Could you please clarify just one more thing:
In the "TRM48L950FlashLnk.cmd" file, I see that the nor Flash memory starting and ending address are not listed under the Memory Map or the Section Configuration. Is it not necessary?
We don't have to add NOR flash address to linker command file.
Does the code work for you? I developed this code 10 years ago.