- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. You do not enable your DMA.
2. Your DMADone_flag is not initializes and should be set to 0 (FALSE)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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