5 Replies Latest reply on Nov 14, 2016 1:40 AM by user_1377889

    ADC SAR in BLE

    arturo.chunga.saavedra

      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".