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.

MSP432P401R: not enaugh space in memory

Part Number: MSP432P401R

Hi!

I would like to store an array of 32000 cells of type uint_16. (ADC values). I saw that the max SRAM space is 64KB, so I'm aware that 2B*32000 exceed this memory space. However I saw that the MSP432P401R has 256KB of flash memory and I would like to put my array into this memory (I read that each block size is 4KB, then 4*8=32KB and it should fits for my array).

It's the right way to proceed? And int his case how could I do? Because I tried to declare my array 

uint_fast16_t myArray[32000]

and after that call

MAP_FlashCtl_programMemory((void*)myArray,(void*) 0x...., 32000)

but at compile time the compiler prompted me: "program will not fit into available memory" (I also tried with smaller number of cells to fit into SRAM and the write into flash memory went well).

Thank you in advance,
Regards,

Mattia Ducci

  • Hi Mattia,

    it is not so easy to write the data to the flash memory. Your definition assumes, that the memory is in the SRAM space, which is to small. You have to define a It depends on your use case how to store the data.

    Are you aware of the programming speed in flash for your ADC data?
    If you are using flash memory, it is treated like const memory. You have to erase it before you could use it. To write to the memory it will also take a while.

    I'm not sure if this is possible in your use case.

    Best regards,

  • An external EEPROM might also be another solution.
  • Thank you :)

    In my project I would like to sample the ADC values and sent it through UART.

    Although in this post I asked for sending in batch a lot of samples, my wish is to send each sample in real time, but seems that the UART is too slow, even if I don't understand why.

    I set the SMCLK to 48MHz

    FlashCtl_setWaitState(FLASH_BANK0, 2);
    FlashCtl_setWaitState(FLASH_BANK1, 2);
    MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
    CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);

    I assigned it to ADC CLOCK (after tested that SMCLK was 48MHz with the function CS_getSMCLK())

    MAP_ADC14_initModule(ADC_CLOCKSOURCE_SMCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_1,0);

    I configured the ADC sample trigger to be sourced from TIMER_A 

    MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false);

    with this parametrisation

    /* Timer_A Continuous Mode Configuration Parameter */
    const Timer_A_UpModeConfig upModeConfig =
    {
            TIMER_A_CLOCKSOURCE_SMCLK,            
            TIMER_A_CLOCKSOURCE_DIVIDER_1,
            3000,
            TIMER_A_TAIE_INTERRUPT_DISABLE,      // Disable Timer ISR, mi serve x ADC
            TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE, // Disable CCR0
            TIMER_A_DO_CLEAR                     // Clear Counter
    };
    
    /* Timer_A Compare Configuration Parameter */
    const Timer_A_CompareModeConfig compareConfig =
    {
            TIMER_A_CAPTURECOMPARE_REGISTER_1,          // Use CCR1
            TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE,   // Disable CCR interrupt, mi serve x ADC
            TIMER_A_OUTPUTMODE_SET_RESET,               // Toggle output bit
            3000                                 //CCR1=CCR0 
    };

    Considered that I would like to sample at 16kHz -> 48Mhz / 3000 = 16kHz, is it right to think that the ADC conversion is done 16.000 times per seconds?

    I configured the UART module with the parameters suggested at this link: 

    //48MHz clock, 115200 baudrate
    const eUSCI_UART_Config uartConfig =
    {
        EUSCI_A_UART_CLOCKSOURCE_SMCLK,          // SMCLK Clock Source
        26,                                     // BRDIV = 78
        1,                                       // UCxBRF = 2
        0,                                       // UCxBRS = 0
        EUSCI_A_UART_NO_PARITY,                  // No Parity
        EUSCI_A_UART_LSB_FIRST,                  // MSB First
        EUSCI_A_UART_ONE_STOP_BIT,               // One stop bit
        EUSCI_A_UART_MODE,                       // UART mode
        EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION  // Oversampling
    };

    and in the main() I have something like these:

    while(1){            
    sprintf(str,"%x",myArray[index]);
                MAP_UART_transmitData(EUSCI_A0_BASE, str[0]);
                MAP_UART_transmitData(EUSCI_A0_BASE, str[1]);
                MAP_UART_transmitData(EUSCI_A0_BASE, str[2]);
                MAP_UART_transmitData(EUSCI_A0_BASE, str[3]);
                MAP_UART_transmitData(EUSCI_A0_BASE, str[4]);
                MAP_UART_transmitData(EUSCI_A0_BASE, '\n');
    }

    I think that with 48Mhz ,against 16kHz of ADC, would have given me enough time to send my adcValue (stored in myArray) between two ADC sampling.

    Where Am I wrong?

    Thank you!,

    Best Regards,

    Mattia Ducci

  • Mattia,

    Couple things. First, make sure you're using a Red Launchpad or Rev C/D silicon or greater. Black LaunchPads contain old experimental silicon that is no longer supported.

    Refer to Section 3 of www.ti.com/.../slaa700

    If you are, you can get a new launchpad here: www.ti.com/.../msp-exp432p401r

    Second. The ADC can only be clocked to 25MHz. Trying to clock the ADC at 48MHz is out of spec.

    On Rev C/D devices, you may want to check your wait state settings: Per Section 5.8 of the datasheet, you can use 1 wait state instead of 2 unless you are using read modes that read margin 0, 1, program verify, or erase verify.

    Per Table 5-36, you can't clock your UART at 48MHz. The max is 24MHz. Also, as you adjust your clock, be sure to adjust the UCBRS and UCBRF and BRDIV values.

    Per Table 5-28, you can't clock your ADC at 48MHz. The max ADC clock the ADC module can handle is 25MHz.

    From there, I would make these changes and rethink your approach to the application. Please look at ADC, Timers and UART examples to get more familiarized with these IP's. I'm going to close this post for now, but as your application develops, please feel free to continue askign questions!!

    dev.ti.com/.../
  • Thank you for your answer. I have the black launchpad..
    Now I will try to adjust my clocks. But what could happen if I continue to use the 48MHz clock? Is this dangerous for the hardware?

    Best regards,
    Mattia Ducci
  • Mattia,

    48MHz clocking of the peripherals is out of specification and we do not guarantee operation and will likely damage the hardware. Please always refer to the datasheet when determining what settings you can set your MCU to.

**Attention** This is a public forum