- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I used the GPIO & Delay to create simple square waveform in main code.
And I can't measure waveform point by ADC module at the same time.
My goal is creating square waveform while measure waveform point by ADC module.
thx~~
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried with CY8CKIT-044 (CY8C4247AZI-M485).
The schematic was
I used
TCPWM to generate the waveform
Timer to generate (about) 1.5us trigger ADC
Pins
Timer Config
TCPWM Config
main.c
Since ADC is triggered every 1.5us, we don't have much time to do with the result of ADC,
so I just get mV value of the ADC and if it's over 2.5V (2500mV), Turn LED on
otherwise turned LED off in the ADC done ISR.
#include "project.h"
#include "stdio.h"
#define LED_ON (0u)
#define LED_OFF (1u)
#define ADC_THD 2500
CY_ISR(adc_isr)
{
uint16_t raw_value ;
int16_t adc_mV ;
adc_done_ClearPending() ;
raw_value = ADC_GetResult16(0) ;
adc_mV = ADC_CountsTo_mVolts(0, raw_value) ;
if (adc_mV >= ADC_THD) {
LED_Write(LED_ON) ;
} else {
LED_Write(LED_OFF) ;
}
}
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
TCPWM_Start() ; /* output wave start */
adc_done_ClearPending() ;
adc_done_StartEx(adc_isr) ;
ADC_Start() ;
}
int main(void)
{
init_hardware() ;
UART_UartPutString("\x1b[2J\x1b[;H") ;
UART_UartPutString("ADC Test\n\r") ;
Timer_Start() ; /* ADC sampling start */
for(;;)
{
}
}
When Ran
Yellow: the output waveform
Blue: ADC Trigger
Magenta: LED output depending on the value of ADC (May be I should have made it opposite)
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It would be nice if you can provide us information about
(1) Which PSoC device are you planning to use?
(2) What is the frequency/period of the square wave?
(3) How often do you want to sample ADC or what is the sample frequency/period of ADC?
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It would be nice if you can provide us information about
(1) Which PSoC device are you planning to use?
A:I want to use the PSoC 4200M.
(2) What is the frequency/period of the square wave?
A:The waveform is below.
(3) How often do you want to sample ADC or what is the sample frequency/period of ADC?
A:I set acquisition time 1.5us.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried with CY8CKIT-044 (CY8C4247AZI-M485).
The schematic was
I used
TCPWM to generate the waveform
Timer to generate (about) 1.5us trigger ADC
Pins
Timer Config
TCPWM Config
main.c
Since ADC is triggered every 1.5us, we don't have much time to do with the result of ADC,
so I just get mV value of the ADC and if it's over 2.5V (2500mV), Turn LED on
otherwise turned LED off in the ADC done ISR.
#include "project.h"
#include "stdio.h"
#define LED_ON (0u)
#define LED_OFF (1u)
#define ADC_THD 2500
CY_ISR(adc_isr)
{
uint16_t raw_value ;
int16_t adc_mV ;
adc_done_ClearPending() ;
raw_value = ADC_GetResult16(0) ;
adc_mV = ADC_CountsTo_mVolts(0, raw_value) ;
if (adc_mV >= ADC_THD) {
LED_Write(LED_ON) ;
} else {
LED_Write(LED_OFF) ;
}
}
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
TCPWM_Start() ; /* output wave start */
adc_done_ClearPending() ;
adc_done_StartEx(adc_isr) ;
ADC_Start() ;
}
int main(void)
{
init_hardware() ;
UART_UartPutString("\x1b[2J\x1b[;H") ;
UART_UartPutString("ADC Test\n\r") ;
Timer_Start() ; /* ADC sampling start */
for(;;)
{
}
}
When Ran
Yellow: the output waveform
Blue: ADC Trigger
Magenta: LED output depending on the value of ADC (May be I should have made it opposite)
moto