cancel
Showing results for 
Search instead for 
Did you mean: 

.bss section data corrupted

Basavanagouda1
Associate II

Hi All,

We using SPC560P development board in our project. We saw board is halt program execution and checked .bss variable values corrupted. 

Could you please help me to understand this issue. Sharing my map file in attachment. 

EPWMD7 values are corrupted. 

Thanks,

Basava.

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
1 ACCEPTED SOLUTION

Accepted Solutions

Check memory allocator, and if heap/stack are colliding.

Check startup code.

Instrument code to monitor the stack and heap. Walk the heap, check for fragmentation, structure corruption, double releases, leaks, etc.

Check _sbrk() code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4

Check memory allocator, and if heap/stack are colliding.

Check startup code.

Instrument code to monitor the stack and heap. Walk the heap, check for fragmentation, structure corruption, double releases, leaks, etc.

Check _sbrk() code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Erwan YVIN
ST Employee

Hello ,

yes , check _sbrk code

please check the PC,LR and R14 with the debugger

Best regards

Erwan

Hi Erwan , Clive

I tried to find out the bug root cause and found the below code is causing that issue.

I tried to read ADC channels value in group using DMA I'm calling below function to do that. Please let me know is there any setting is missed here.

suwAdc0Grp1SampleBuff is a global buffer. ADC group is created with 6 channel and each channel will be 2bytes value.

So, I have created this buffer with 7 element array (7x2 bytes) and I choose Linear buffer option in the SPC5 studio.

Is my DMA configuration and buffer selection is correct?

typedef uint16_t adcsample_t;

adcsample_t suwAdc0Grp1SampleBuff[7];

adc_lld_start_conversion(&ADCD1, &adc0_group_adc0_grp1, &suwAdc0Grp1SampleBuff[0], 1);

void adc_lld_setup_scan_conversion(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth) {

#if SPC5_ADC_DMA_MODE == SPC5_ADC_DMA_ON

 vuint8_t *src;

 adcp->samples = samples;

 adcp->depth  = depth;

 adcp->grpp   = grpp;

 src = ((vuint8_t *)&adcp->adc_tagp->CDR[adcp->grpp->init_channel].R) + 2;

 /* Setting up DMA TCD parameters.*/

 edmaChannelSetup(adcp->adc_dma_channel,                  /* channel.         */

          src,                           /* src.     */

          adcp->samples,                      /* dst.           */

          0,                            /* soff, advance by four.  */

          2,                            /* doff, advance by two.  */

          1,                            /* ssize, 16 bits transfers.*/

          1,                            /* dsize, 16 bits transfers.*/

  2,                            /* nbytes */

          (uint32_t)adcp->depth,                  /* iter.          */

          CPL2((uint32_t)adcp->grpp->num_channels * 4U),      /* slast.          */

          (CPL2((uint32_t)adcp->grpp->num_channels * (uint32_t)adcp->depth * sizeof(adcsample_t))), /* dlast.          */

          EDMA_TCD_MODE_DREQ | EDMA_TCD_MODE_INT_END);   /* mode.          */

 /* Active DMA.*/

 adcp->adc_tagp->DMAE.R = ADC_DMAE_DMAEN;

 /* initialize registers for dma cases */

 adc_initialize_registers_dma(adcp);

#else /* SPC5_ADC_DMA_MODE == SPC5_ADC_DMA_OFF */

 adcp->samples = samples;

 adcp->depth  = depth;

 adcp->grpp   = grpp;

 /* initialize rx_ptr and rx_cnt */

 adcp->rx_ptr  = adcp->samples;

 adcp->rx_cnt  = adcp->depth * adcp->grpp->num_channels;

 /* initialize registers for non-dma cases */

 adc_initialize_registers_nondma(adcp);

#endif /* SPC5_ADC_DMA_MODE == SPC5_ADC_DMA_OFF */

#if SPC5_ADC_DMA_MODE == SPC5_ADC_DMA_ON

 /* Starting DMA channels.*/

 edmaChannelStart(adcp->adc_dma_channel);

#endif /* SPC5_ADC_DMA_MODE */

 /* Starts conversion.*/

 adcp->adc_tagp->MCR.B.NSTART = 1U;

}

Thanks,

Basava.

Hi Erwan,

I tried to find out the bug root cause and found the below code is causing that issue.

I tried to read ADC channels value in group using DMA I'm calling below function to do that. Please let me know is there any setting is missed here.

adcsample_t suwAdc0Grp1SampleBuff[7];

  • We are sending 1 in the depth argument. Is it correct?
  • What is meant by depth here?
  • do we need to send 6 in the depth argument to read all channels?

Please advise.

adc_lld_start_conversion(&ADCD1, &adc0_group_adc0_grp1, &suwAdc0Grp1SampleBuff[0], 1);

void adc_lld_setup_scan_conversion(ADCDriver *adcp, const ADCConversionGroup *grpp, adcsample_t *samples, size_t depth) {

#if SPC5_ADC_DMA_MODE == SPC5_ADC_DMA_ON

 vuint8_t *src;

 adcp->samples = samples;

 adcp->depth  = depth;

 adcp->grpp   = grpp;

 src = ((vuint8_t *)&adcp->adc_tagp->CDR[adcp->grpp->init_channel].R) + 2;

 /* Setting up DMA TCD parameters.*/

 edmaChannelSetup(adcp->adc_dma_channel,                  /* channel.         */

          src,                           /* src.     */

          adcp->samples,                      /* dst.           */

          0,                            /* soff, advance by four.  */

          2,                            /* doff, advance by two.  */

          1,                            /* ssize, 16 bits transfers.*/

          1,                            /* dsize, 16 bits transfers.*/

  2,                            /* nbytes */

          (uint32_t)adcp->depth,                  /* iter.          */

          CPL2((uint32_t)adcp->grpp->num_channels * 4U),      /* slast.          */

          (CPL2((uint32_t)adcp->grpp->num_channels * (uint32_t)adcp->depth * sizeof(adcsample_t))), /* dlast.          */

          EDMA_TCD_MODE_DREQ | EDMA_TCD_MODE_INT_END);   /* mode.          */

 /* Active DMA.*/

 adcp->adc_tagp->DMAE.R = ADC_DMAE_DMAEN;

 /* initialize registers for dma cases */

 adc_initialize_registers_dma(adcp);

#else /* SPC5_ADC_DMA_MODE == SPC5_ADC_DMA_OFF */

 adcp->samples = samples;

 adcp->depth  = depth;

 adcp->grpp   = grpp;

 /* initialize rx_ptr and rx_cnt */

 adcp->rx_ptr  = adcp->samples;

 adcp->rx_cnt  = adcp->depth * adcp->grpp->num_channels;

 /* initialize registers for non-dma cases */

 adc_initialize_registers_nondma(adcp);

#endif /* SPC5_ADC_DMA_MODE == SPC5_ADC_DMA_OFF */

#if SPC5_ADC_DMA_MODE == SPC5_ADC_DMA_ON

 /* Starting DMA channels.*/

 edmaChannelStart(adcp->adc_dma_channel);

#endif /* SPC5_ADC_DMA_MODE */

 /* Starts conversion.*/

 adcp->adc_tagp->MCR.B.NSTART = 1U;

}

Thanks,

Basava