Settings to be given to make a single channel SAR ADC operate at 1Msps

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hi All,

   

I am not sure if all of you are aware of this. You need to configure Vref to "Internal 1.024 V bypassed" from the drop-down list in SAR ADC to obtain 1Msps of conversion rate. Also averaging option has to be disabled.

   

One important point to be noted is that to obtain exact 1Msps sampling rate, the IMO should be configured to be 36 MHz.

   

Regards,

   

Asha

0 Likes
45 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

 Your BuffSizde should be set to 1000, the for loop

   

will test before executing, so it hits 1000 and loop

   

terminates with last i used of 999 in array index. So

   

i ranges 0 - 999 = 1000 array locations.

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Hi thank you for the fast answer. So take a look in my sketch, I think I corrected. Now my problem is with de IMO and Uart, because the Mcu speed is too slow, but when I increase it, the UART stops to work.

   

 

   

Again, I want to sample 10.000 samples fastest I can, and then send to a computer by UART.

   

 

   

#include <project.h>

   

#include <device.h>

   

#include "stdio.h"

   

 

   

 

   

#define TRANSMIT_BUFFER_SIZE  16

   

#define BuffSize 999

   

 

   

void main()

   

{

   

    /* Variable to store ADC result */

   

    uint8 Output [1000];

   

    char TransmitBuffer[TRANSMIT_BUFFER_SIZE];

   

int16 i=0;

   

   

    

   

    /* Start the components */

   

    ADC_Start();

   

    UART_1_Start(); 

   

PWM_1_Start();

   

    ADC_StartConvert();

   

      

   

    for(;;)

   

    {        

   

       for (i=0; i < BuffSize; i++)       // Loop straightened. Taken from the source of ADC.c

   

{

   

               while(!(ADC_SAR_CSR1_REG & ADC_SAR_EOF_1)){}

   

ADC_SAR_CSR1_REG = ADC_SAR_EOF_1;

   

Output= CY_GET_REG8(ADC_SAR_WRK_PTR);

   

}

   

for (i=0; i < BuffSize; i++)       // Loop straightened. Taken from the source of ADC.c

   

{

   

            sprintf(TransmitBuffer, "%d\r\n", Output);

   

            UART_1_PutString(TransmitBuffer);

   

}

   

        }

   

    }

   

 

   

Ps: I used the example project (ADC UART) to do mine.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Hi, I modify the project and use the DMA, there is no erros but didn't work.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

1. You do not enable your DMA.

   

2. Your DMADone_flag is not initializes and should be set to 0 (FALSE)

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 Take a look Now, I did the changes but still not working, and i don't Know why.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are witing

   

    CyDmaTdSetAddress(DMA_TD[0], LO16((uint32)ADC_SAR_SAR_WRK1_REG), ...
but you need 1st the address of a register and 2nd a 16 bit register, not an 8 bit one.

   

So give instead

   

    CyDmaTdSetAddress(DMA_TD[0], LO16((uint32)ADC_SAR_SAR_WRK_PTR), ...

   

a chance.

   

 

   

Bob

0 Likes