Other Parts Discussed in Thread: CC2530
i wrote a program according to which the ZED will send the data from its internal temperature sensor to the ZC which will analyze this data and will send a value from ZC to ZED which will be used by the ZED to create a pwm of a known dutycycle which would be able to run a motor ..
when i connected an external sensor using this line
int16 readTemp(void)
{
unsigned char i;
unsigned short AdcValue;
unsigned short value;
unsigned int temp;
// #if defined (HAL_MCU_CC2530)
#define ADC_SINGLE_CONVERSION(settings) \
do{ ADCCON3 = (settings); }while(0)
#define ADC_SAMPLE_SINGLE() \
do { ADC_STOP(); ADCCON1 |= 0x40; } while (0)
#define ADC_SAMPLE_READY() (ADCCON1 & 0x80)
#define ADC_STOP() \
do { ADCCON1 |= 0x30; } while (0)
AdcValue = 0;
for( i = 0; i < 4; i++ )
{
ADC_SINGLE_CONVERSION(HAL_ADC_REF_AVDD | HAL_ADC_DEC_512 | HAL_ADC_CHN_AIN3); // ʹÓÃ1.25VÄÚ²¿µçѹ£¬12λ·Ö±æÂÊ£¬ADԴΪ£ºÎ¶ȴ«¸ÐÆ÷
ADC_SAMPLE_SINGLE(); //¿ªÆôµ¥Í¨µÀADC
while(!ADC_SAMPLE_READY()); //µÈ´ýADת»»Íê³É
value = ADCL >> 2; //ADCL¼Ä´æÆ÷µÍ2λÎÞЧ
value |= (((UINT16)ADCH) << 6);
AdcValue = value; //AdcValue±»¸³ÖµÎª4´ÎADÖµÖ®ºÍ
}
//value = AdcValue>>2;
temp = ((AdcValue)*27.027);
/* if( temp >= 100)
{
return 100;
}
else if (temp <= 0) {
return 0;
}
else {*/
return temp;
//}
}
i just put this lines instead of the function which get temp values froom the internal sensor of cc2530 . but the code is not working as in it works in internal sensor ..