Hot!PIC32MZ DA DDR Example Questions

Author
Vargoth
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2018/02/26 17:18:02
  • Location: 0
  • Status: offline
2018/03/13 17:29:49 (permalink)
0

PIC32MZ DA DDR Example Questions

I am using the PIC32MZ DA Starter kit with internal DDR memory and trying to determine how to read/write to the internal DDR. The DDR example in Harmony 2.05.1 doesn't have any comments on the FSM used to perform the read/write operations and I am having trouble puzzling through how the code accesses the DDR. Here is an excerpt from the DDR the FSM:
 
case APP_STATE_WRITE:
{
if(BSP_SWITCH_STATE_PRESSED == BSP_SwitchStateGet(BSP_SWITCH_1))
{
appData.state = APP_STATE_INIT;
}
if(appData.count == 0)
{
appData.count = LED_TOGGLE_COUNT;
BSP_LEDToggle(BSP_LED_1);
BSP_LEDToggle(BSP_LED_2);
}
appData.count--;
if ( appData.addr < (DDR_START + MEM_SIZE))
{
strt_addr = appData.addr;
while (appData.addr < strt_addr + READ_WRITE_BLOCK)
{
(*(volatile unsigned int *)(appData.addr)) = appData.addr;
appData.addr += 4;
}
}
else
{
appData.addr = DDR_START;
appData.state = APP_STATE_READ;
appData.count = 0;
BSP_LEDOff(BSP_LED_1);
BSP_LEDOff(BSP_LED_2);
BSP_LEDOff(BSP_LED_3);
}
break;
}
 
I changed the text of the only code that makes sense as performing the write operation to the DDR but to me it only looks like the code is incrementing the data address counter as there are no other functions called to access the DDR and no actual data is ever defined in the example. Am I missing something as it seems like this example is just counting up, then down, and flashing different LED's during the different states and never actually accessing the DDR? The main.c only calls the sys_tasks function which only calls the Application FSM...
 
The program builds and programs fine (and the LEDs flash in the proper sequence) but I can't tell if the DDR is actually being written to or read from.
 
Thanks in advance!!
Patrick
 
P.S. I assume that the internal DDR memory is volatile and that if I wish to store variables/data that I will need an external EEPROM, correct? Or is there another non-volatile storage medium that I can use to store variables when the PIC loses power (I don't see anything in the datasheet for the PIC32MZ DA series)?
 
#1

2 Replies Related Threads

    simong123
    Lab Member No. 003
    • Total Posts : 1283
    • Reward points : 0
    • Joined: 2012/02/07 18:21:03
    • Location: Future Gadget Lab (UK Branch)
    • Status: offline
    Re: PIC32MZ DA DDR Example Questions 2018/03/13 20:41:27 (permalink)
    0
    The DDR DRAM appears as any other memory, it doesn't need a special function to write to it.
    Vargoth
    (*(volatile unsigned int *)(appData.addr)) = appData.addr;

    This line writes the value appData.addr to the DRAM at address pointed to by appData.addr.
    In effect (with type casting/brackets removed for clarity) it is:-
    *appData.addr = appData.addr;

     
    Vargoth
    P.S. I assume that the internal DDR memory is volatile and that if I wish to store variables/data that I will need an external EEPROM, correct? Or is there another non-volatile storage medium that I can use to store variables when the PIC loses power (I don't see anything in the datasheet for the PIC32MZ DA series)?

    If you only need to update the data very occaisonally you can reserve a block of program flash memory and use that, otherwise an external EEPROM is your best bet.
    #2
    Vargoth
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2018/02/26 17:18:02
    • Location: 0
    • Status: offline
    Re: PIC32MZ DA DDR Example Questions 2018/03/14 03:34:44 (permalink)
    0
    Thanks simong123! 
     
    I feel a little stupid now... I'm so used to using external memory that I hadn't even considered that the internal DDR was just accessed like an internal address.
    #3
    Jump to:
    © 2018 APG vNext Commercial Version 4.5