- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to use the ADC SAR UDB in my PSoC BLE, i think theres something wrong in my code because there's no response on the Serial Communication (I only see my first message). This is my code:
#include "project.h"
#include <stdio.h>
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
char str[12]={'\0'};
uint16 conversion=0;
uint16 voltage=0;
ADC_Start();
IDAC_Start();
UART_Start();
UART_UartPutString("Hi everyone");
for(;;)
{
ADC_StartConvert();
ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);
conversion=ADC_GetResult16(0);
voltage=ADC_CountsTo_mVolts(0,conversion);
ADC_StopConvert();
sprintf(str,"%d",conversion);
UART_UartPutString(str);
CyDelay(500);
}
}
When I use the debbuger I see that my data is lost in the transformation with the line "voltage=ADC_CountsTo_mVolts(0,conversion);". But, the "ADC_GetResult16(0);" does give me the data (Example 1675, out of 2047), but the it doesn't convert it to mili volts. Does anyone know what is happening?
Pd. In my TopDesign I only have IDAC, ADC SAR Seq, SCB (as UART) and I am using Arduino Monitor Serie where I only see the first message: "Hi everyone".
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is your program. I also added a die temp device so you can read two channels of the ADC. Jumper P3.2 to 3.3 Volts on J1. The reason you where not seeing a reading on the voltage was you where not printing it out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum, Arturo!
There are some settings I would suggest:
Use "Hi everyone\n\r" so that the output lines get separated. same with other output.
Project->Build settings -> compiler -Optimization set to "none"
-> Linker set Use newlib nano to true
set User newlib nano float formatting to true
Workspace explorer - > System set Heap size to 0x0200
You do not need to use StartConvert and StopConvert() within the main-loopm use StartConvert() outside the loop.
Your missing data may result from some optimization which now is switched off.
Next time (it is far more easier for us to check) please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much Bob. I made this change and the transfer data got done.
- 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
Thank you very much bobgoar, this will also help me. There is really good people in this forum 😄
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Always at your service, Arturo!
Bob & Bob ;-))