Other Parts Discussed in Thread: SYSBIOS, CC2640R2F
Hi, Team
Thank you so much for the reply, and sorry for the late reply,
I am trying to implement adc concept using cc2650 using DS600+ but i have some doubt regarding this
/*
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ======== adcsinglechannel.c ========
*/
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* Driver Header files */
#include <ti/drivers/ADC.h>
#if defined(CC2650DK_7ID) || defined(CC1310DK_7XD)
#include <ti/drivers/PIN.h>
#endif
/* Example/Board Header files */
#include "Board.h"
#define ADC_CONV_MIN_VAL 1200
#define ADC_CONV_MAX_VAL 4095
#define ROOM_TEMP_MIN 2500
#define ROOM_TEMP_MAX 3500
#define ADC_CELCIUS_CONV_CONST 509
/* ADC sample count */
#define ADC_SAMPLE_COUNT (10)
/*Task Specific defines */
#define TASKSTACKSIZE (768)
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
/* Pin driver handles */
static PIN_Handle buttonPinHandle;
/* Global memory storage for a PIN_Config table */
static PIN_State buttonPinState;
// Temperature sensor related variables declaration
/* ADC conversion result variables */
uint16_t adcValue1[50]={0};
const float adc_conv_volt_const = 0.293040;
const float adc_cel_conv_const = 6.45;
unsigned long volt = 0;
float cel = 0;
int g_Celsius[50]={0};
/*
* Application button pin configuration table:
* - Buttons interrupts are configured to trigger on falling edge.
*/
PIN_Config buttonPinTable[] = {Board_DIO21 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,PIN_TERMINATE};
/*
* ======== taskFxn1 ========
* Open a ADC handle and get a array of sampling results after
* calling several conversions.
*/
Void taskFxn0(void)
{
/*board initialization for ADC Pins*/
Board_initADC();
ADC_Handle adc;
ADC_Params params;
int_fast16_t res;
char currVal = 0;
char i = 0;
//clearing the buffer
for(i = 0; i<50; i++)
{
g_Celsius[i] = 0;
adcValue1[i] = 0;
}
PIN_setOutputValue(buttonPinHandle, Board_DIO21, currVal); // for temperature sensor active
ADC_Params_init(¶ms);
adc = ADC_open(Board_ADC0, ¶ms);
if (adc == NULL)
{
System_abort("Error initializing ADC channel 1\n");
}
else
{
System_printf("ADC channel 1 initialized\n");
}
ADC_close(adc);
}
/*
* ======== main ========
*/
int main(void)
{
Task_Params taskParams;
/* Call board init functions */
Board_initGeneral();
buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
if(!buttonPinHandle) {
System_abort("Error initializing button pins\n");
}
/* Create tasks */
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)taskFxn0, &taskParams, NULL);
/* SysMin will only print to the console when you call flush or exit */
System_flush();
BIOS_start();
return (0);
}
this is my code in this i am not getting accurate result in res = ADC_convert(adc, &adcValue1[i]); but i am getting adcValue1 correctly can you please help me? i am so enthusiastics to learn about it