hi, can CC2430 measure the EXTERNAL temperature??? how??? anyone know this?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi.
Yes it can. Either using the on-board temperatur sensor or connect a external sensor to the ADC.
Check the following design note:
DN102 -- SoC Temperature Sensor
Regards,
Kjetil
Hi,
Just wrote this quick code based on the design note and Timer 4. Did not have the chance to test this myself, but should not be far from working if it does not work as-is.
Let me know if you have any questions.
#include "iocc2430.h"
#define SAMPLE_TEMP_SENSOR(v) \
do { \
ADCCON2 = 0x3E; \
ADCCON1 = 0x73; \
while(!(ADCCON1 & 0x80)); \
v = ADCL; \
v |= (((unsigned int)ADCH) << 8); \
} while(0)
#define CONST 0.61065 // (1250 / 2047)
#define OFFSET_DATASHEET 750
#define OFFSET_MEASURED_AT_25_DEGREES_CELCIUS 29.75
#define OFFSET (OFFSET_DATASHEET + OFFSET_MEASURED_AT_25_DEGREES_CELCIUS) // 779.75
#define TEMP_COEFF 2.43
float getTemp(void){
unsigned int adcValue;
float outputVoltage;
SAMPLE_TEMP_SENSOR(adcValue);
// Note that the conversion result always resides in MSB section of ADCH:ADCL
adcValue >>= 4; // Shift 4 due to 12 bits resolution
outputVoltage = adcValue * CONST;
return ((outputVoltage - OFFSET) / TEMP_COEFF);
}
// This interrupt routine should be run every 5 kHz (every 200 usec)
#pragma vector = T4_VECTOR
__near_func __interrupt void t4_isr(void)
{
T4OVFIF = 0; // Clears the module interrupt flag.
float temperature = getTemp(); // Get the current temperature
T4IF = 0; // Clears the CPU interrupt flag.
}
void main(void)
{
// This example runs on 16 MHz RC oscillator and the Timer Tick Speed is 16 MHz
T4CC0 = 0xC8; // Timer counts from this value down to 0 at 1 MHz - timeout every 200 usec -> 5 kHz
T4CTL = 0x91; // Prescaler is tick / 16 -> each timer tick is 1 us. Timer used in down mode
T4IE = 1; // Timer 4 interrupt enable
EA = 1; // Global interrupt enable
while (1);
}
hi, thank you for the help. i have no questions about this. i'm looking for the difference of non-volatile memory between cc2430EM cordinator and the cc2430DB. in the cc2430 datasheet and in all the documentation that i have i have found
Hello,
I'm using the Z stack with the cc2430db and i want to measure the exterior temperature and send it to the coordinator
I tried with this program but this is an error that i don't find to resolve it ?
This is the program
#define SAMPLE_TEMP_SENSOR(v) \
do { \
ADCCON2 = 0x3E; \
ADCCON1 = 0x73; \
while(!(ADCCON1 & 0x80)); \
v = ADCL; \
v |= (((unsigned int)ADCH) << 8); \
} while(0)
#define const 0.61065 // (1250 / 2047)
#define OFFSET_DATASHEET 750
#define OFFSET_MEASURED_AT_25_DEGREES_CELCIUS 29.75
#define OFFSET (OFFSET_DATASHEET + OFFSET_MEASURED_AT_25_DEGREES_CELCIUS) // 779.75
#define TEMP_COEFF 2.43
float getTemp(void){
unsigned int adcValue;
float outputVoltage;
SAMPLE_TEMP_SENSOR(adcValue);
// Note that the conversion result always resides in MSB section of ADCH:ADCL
adcValue >>= 4; // Shift 4 due to 12 bits resolution
outputVoltage = adcValue * CONST;
return ((outputVoltage - OFFSET) / TEMP_COEFF);
}
The error that i have
Error[Pe065]: expected a ";" C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Samples\SampleApp\Source\SampleApp.c 411
Warning[Pe012]: parsing restarts here after previous syntax error C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Samples\SampleApp\Source\SampleApp.c 422
Error while running C/C++ Compiler
zmac.c
the first error appear in the line where i have '' float getTemp(void){ ''
so i don't find where i add a ";"
can you help me
best regards
Oussama
Hello!
I am new at IAR and cc2430 and its seems to me that I have the same problem that Oussama has.
I have this code:
#include "iocc2430.h"
#define SAMPLE_TEMP_SENSOR (v) \
do { \
ADCCON2 = 0x3E; \
ADCCON1 = 0x73; \
while(!(ADCCON1 & 0x80)); \
v = ADCL; \
v |= ((unsigned int)ADCH) << 8); \
} while(0)
#define CNST 0.61065 // (1250 / 2047)
#define OFFSET_DATASHEET 743
#define TEMP_COEF 2.45
float getTemp(void)
{
unsigned int adcValue;
float outputVoltage;
SAMPLE_TEMP_SENSOR (adcValue);
// the conversiton result always resides in MSB of ADCH:ADCL
adcValue >>= 4; // shift 4 due to 12 bits resolution
outputVoltage = adcValue * CNST;
return ((outputVoltage - OFFSET_DATASHEET)/TEMP_COEF);
}
and I have these erros and warnings:
Error[Pe020]: identifier "v" is undefined C:\Texas Instruments\ZStack-1.4.3-1.2.0\Projects\zstack\Samples\Location\Source\RefNode.c 590
Error[Pe065]: expected a ";" C:\Texas Instruments\ZStack-1.4.3-1.2.0\Projects\zstack\Samples\Location\Source\RefNode.c 590
Warning[Pe549]: variable "adcValue" is used before its value is set C:\Texas Instruments\ZStack-1.4.3-1.2.0\Projects\zstack\Samples\Location\Source\RefNode.c 593
I am writing all the code in the .c, should I write the first define in the .h? To speak the truth, I don't understand the first define, I just copied it from the design note dn102.
Can you give me a help?
Kind Regards,
maria
I found the problem to this 2 errors and warning: lack of a ( and an extra space between SAMPLE_TEMP_SENSOR and (adcValue).
But now I have another error:
Error[e16]: Segment CODE_C (size: 0x3ef align: 0) is too long for segment definition. At least 0xc2 more bytes needed. The problem occurred while processing the segment placement command "-Z(CODE)CODE_C=_CODE_START-_CODE_END", where at the moment of placement the available memory ranges were "CODE:25d3-28ff"
Reserved ranges relevant to this placement:
CODE:0-85 INTVEC
CODE:86-165 CSTART
CODE:166-e99 RCODE
CODE:e9a-1627 NEAR_CODE
CODE:1628-24d9 BANK_RELAYS
CODE:24da-25d2 XDATA_ID
CODE:25d3-28ff CODE_C
BIT:0-7 BREG
BIT:80-97 SFR_AN
BIT:a8-af SFR_AN
BIT:b8-c7 SFR_AN
BIT:d8-df SFR_AN
BIT:e8-ef SFR_AN
Does anyone knows what this means and give me a help?
Thanks!
Take a look in your f8w2430.xcl file:
In there, you will find a line that says: -D_CODE_END=0x28FF
Your error message says that you need "at least 0xc2 more bytes...", so I would go for a 0x100 to leave some spare
Therefore, change the line in in f8w2430.xcl to: -D_CODE_END=0x29FF and see if that clears your error
Hello Maria,
I'm using the CC2530 and IAR Embedded workbench.
I'm trying to program the ADC for a single ended,single channel conversion.
Here's my code.
/******************************************************************************
Filename: adc.c
These functions/macros simplifies usage of the ADC.
******************************************************************************/
#include "adc.h"
/******************************************************************************
* @fn adcSampleSingle
*
* @brief
* This function makes the adc sample the given channel at the given
* resolution with the given reference.
*
* @param uint8 reference
* The reference to compare the channel to be sampled.
* uint8 resolution
* The resolution to use during the sample (8, 10, 12 or 14 bit)
* uint8 input
* The channel to be sampled.
*
* @return int16
* The conversion result
*
******************************************************************************/
int16 adcSampleSingle(uint8 reference, uint8 resolution, uint8 channel)
{
int16 value;
#ifndef ADC_ENABLE_CHANNEL
#define ADC_ENABLE_CHANNEL
ADC_ENABLE_CHANNEL(channel);
ADCIF = 0;
ADC_SINGLE_CONVERSION(reference | resolution | channel);
while(!ADCIF);
value = (ADCH << 8) & 0xff00;
value |= ADCL;
ADC_DISABLE_CHANNEL(channel);
#endif
// The variable 'value' contains 16 bits where
// bit 15 is a sign bit
// bit [14 .. 0] contain the absolute sample value
// Only the r upper bits are significant, where r is the resolution
// Resolution:
// 12 -> [14 .. 3] (bitmask 0x7FF8)
// 10 -> [14 .. 5] (bitmask 0x7FE0)
// 9 -> [14 .. 6] (bitmask 0x7FC0)
// 7 -> [14 .. 8] (bitmask 0x7F00)
return value;
}
/***********************************************************************************
Copyright 2007 Texas Instruments Incorporated. All rights reserved.
I got this warning:
Warning[Pe549]: variable "value" is used before its value is set C:\softwareexamples\source\components\radios\cc2530\adc.c 59
I saw it on your post , you faced the same problem. How did you resolve this?
Are you done with the ADC program?
Hi All,
I am new to the CC2430.. I want to interface some sensor to the CC2430 SOC_BB board, My sensor gives the analog output.
I dont know which pin i should use (which pin supports ADC) to the ADC and dont know how to use the ADC in CC2430..
Can any one help me to do this.
I need some links or docs which provide the above information..
thanks
chethan
Hello chethan and renzo !
cc2430 has an internal temperature sensor. You can see how to use it in design note 102 (dn102).
I am reading temperature with cc2430 but I am using an external sensor. I am reading the value from an ADC pin.
To learn to work with ADC I suggest that you read pages 128 to 133 from cc2430 datasheet.
You can find this files that I mentioned, googleing it.
Hope this helps! If you have any more questions be free to ask.
Hi, I'm using the Port 'O' of cc2530 for sensor data reading purpose , I have connected two types of sensor to the PORT0 of the ADC, 1. ADC sensor which outputs analog voltage which is ranging from 1 to 3 volt, I have interfaced this to pin 6 of port 0(P0.6). 2. I2C based sensor this one I have interfaced to P0.0 and P0.1 . Here I have used Bit bang method to interface this sensor to Cc2530,. void sensor_read(){ float analog= HalAdcRead (0x40, ADC_12bit);// I have used function which is present in TIMAC cc2530 uint8 I2c_out= Read_I2C_BITBANG(); // I have implemented this } This will be running continuously i.e for evrery 10 minits sensor_read fun will be called. First time it gives the correct out put but in the second time reading ADC read out put vary though my sensor analog output voltage is constant . what may be the problem ..? How to make the port setting to default status( when the controlled is started )..?