cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

New Contributor II

Hi,

I am working on a PSoC 100 (CY8C5888AXI-LP096) based embedded system. I need to do a number (approximates 70 times during a run) of ADC readings( LTC1859 ), each ADC readings are made using the SPI. For SPI I am using DMA to send and read the data, The SPI setup with DMA is shown below in the attachment.

In the main program I am enabling all the global interrupts and setting a watch dog timer and its reset connections as shown below.

   //start the SPI,I2C and UART components

    SPI_Start();

  

    CyGlobalIntEnable; /* Enable global interrupts. */

    CyWdtStart(CYWDT_1024_TICKS, CYWDT_LPMODE_NOCHANGE);

   

    for(;;) {

        CyWdtClear();

The ADC SPI related code is attached below. whenever the read_adc_data() method is called, Its calling the send_spi_dma to read the response from the ADC.

Full related code is attached below.

The Issue I am facing is, I am making ADC calls 64 times in a loop dividing it in a 4 16 loop count, The ADC response is working fine and i am receiving the values up to 48 readings, once the last loop cycle begins between the 49th call to 52 ADC call, the program is RESETTING and all the data and program pointers are getting lost, When i tried to debug the issue, i went inside the DMA calls and checked the response is not received and the MCU is stuck in a loop, and after certain time its triggering the reset.

the related code part is shown below.

while(!(SPI_ReadTxStatus() & SPI_STS_SPI_DONE)) {}

what I want to know is what is causing the reset of the running program,

  • Is the reset is because the program is stuck in a loop and the watchdog timer is triggering the reset?
  • Is it related to stack issue?, if it is is there any way to increase the available stack?
  • Is there any limitations with the DMA?
  • Or is it related to ADC( LTC1859 ) issue and the speed?,

I have attached the relevant datasheet and the code below, if anyone knows please guide me what i am doing wrong.

 

0 Likes
Reply
1 Solution
Honored Contributor II

KaGa,

I  am away from my computer, so can't open the project. I believe such behavior can be caused by wrong DMA settings. For example when the writing address was continuously incremented past end of the destination buffer, so eventually it overrides whatever registers in memory with random values.

/odissey1

View solution in original post

2 Replies
Honored Contributor II

KaGa,

I  am away from my computer, so can't open the project. I believe such behavior can be caused by wrong DMA settings. For example when the writing address was continuously incremented past end of the destination buffer, so eventually it overrides whatever registers in memory with random values.

/odissey1

View solution in original post

New Contributor II

Yes, The DMA configuration was the issue,

When the main method was calling read_adc_data() method, It was calling config_spi_dma() method to configure the DMA, This setting causing the issue to put the read memory outside and it was triggering the reset.

I moved the config_spi_dma(); outside and the issue got resolved.

uint16 read_adc_data(uint16_t channel_add){

    uint8_t lcount = 0;

    uint16_t data_get[1] = {0};

    config_spi_dma(); // I moved this settings to main and problen got resolved

    uint16_t content[1] = { channel_add };       

    while(lcount < 5){

        send_spi_dma(content, data_get, 1); // ARRAY_SIZE(data_get)

        lcount += 1;

    }

    lcount = 0;

    return data_get[0];

}

0 Likes
Reply