- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I'm a newbie for using PSoC. I don't really understand how to use SAR ADC in PSoC. I'm trying to get the digital input from piezoelectric ceramics and also the analog input (mvolt). But I can't get the voltage result. I'm using the following code :
#include "project.h"
#include "stdio.h"
#include "stdlib.h"
char data[60];
uint16_t raw;
float32_t v;
int main(void)
{
__enable_irq(); /* Enable global interrupts. */
ADC_Start();
ADC_StartConvert();
UART_1_Start();
for(;;)
{
if (ADC_IsEndConversion(CY_SAR_RETURN_STATUS)){
raw = ADC_GetResult16(0);
v = ADC_CountsTo_mVolts(0,raw);
sprintf(data,"v= %f mv raw= %d \n",v,raw);
}
UART_1_PutString(data);
CyDelay(100);
}
}
/* [] END OF FILE */
Is there something wrong with the code?
Thank you for your help,
Tita
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Printing floats needs some settings:
Set "use newlib nano" to true (Project butld settings -> linker)
Set "use newlib nano float formatting" to true (Project build settings -> linker)
Set "Heap Size" to (at least) 0x0200 (System view)
That should do the job
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Printing floats needs some settings:
Set "use newlib nano" to true (Project butld settings -> linker)
Set "use newlib nano float formatting" to true (Project build settings -> linker)
Set "Heap Size" to (at least) 0x0200 (System view)
That should do the job
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it work.
Thank you for your help
Tita