Showing posts with label CC2541. Show all posts
Showing posts with label CC2541. Show all posts

Wednesday, March 9, 2016

CC253x/CC254x IO Pin mapping to SmartRF05EB

CC253x/CC254x IO Pin mapping to SmartRF05EB are listed in the followings:



Wednesday, August 26, 2015

How to create a periodic event in TI Z-Stack or BLE-Stack

The following codes are example to start PERIODIC_EVT every second and you can do any periodic processing in PERIODIC_EVT.

//Put where you want to start PERIODIC_EVT
osal_start_timerEx( XXX_TaskID, SENSOR_READ_EVT, 1000 );

//For Z-Stack, create PERIODIC_EVT processing in zcl_XXX_event_loop
//For BLE-Stack, create PERIODIC_EVT processing in xxx_ProcessEvent
  if( events & PERIODIC_EVT )
  {
    //Do things that need periodic processing here!
    ...
    osal_start_timerEx( XXX_TaskID, PERIODIC_EVT, 1000 );
    return (events ^ PERIODIC_EVT);
  }

Wednesday, December 4, 2013

CC2530/CC2541 ADC Howto in TI Z-Stack/BLE Stack

It is always a mystery to beginner to use ADC on CC2530/CC2541. Here, I post how to use TI Z-Stack/BLE Stack API to read ADC value on CC2530/CC2541. I hope this post can help anyone who struggles on CC2530/CC2541 ADC usage. In the followings, I show how to use P0_2 as ADC input, HAL_ADC_REF_125V as reference voltage, and HAL_ADC_RESOLUTION_10, HAL_ADC_RESOLUTION_12, HAL_ADC_RESOLUTION_14 as ADC resolution respectively.

1.  Read ADC value from P0_2 using HAL_ADC_REF_125V as reference voltage and HAL_ADC_RESOLUTION_10 as ADC resolution.

        uint16 adc_ain2=0;
        HalAdcSetReference(HAL_ADC_REF_125V);
        adc_ain2=HalAdcRead(HAL_ADC_CHN_AIN2,HAL_ADC_RESOLUTION_10);



The max measurable voltage of P0_2 is 1.15 because I am using HAL_ADC_REF_125V as reference voltage here. If the input voltage is larger than 1.15V, the ADC reading adc_ain2 will be always 511. If I connect P0_2 to 0.5V, I will have ADC reading adc_ain2=223. Then, we can convert the reading 223 to measured voltage using the following equation.
measured voltage = 1.15x223/511=0.501...

2. If I change  HAL_ADC_RESOLUTION_12 (the max reading is 2047) as ADC resolution and connect P0_2 to 0.5V, I will have ADC reading adc_ain2=886. Then, we can convert the reading 889 to measured voltage using the following equation.
measured voltage = 1.15x889/2047=0.499...


3. If I change  HAL_ADC_RESOLUTION_14 (the max reading is 8191) as ADC resolution and connect P0_2 to 0.5V, I will have ADC reading adc_ain2=3550. Then, we can convert the reading 3550 to measured voltage using the following equation.
measured voltage = 1.15x3550/8191=0.498...