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.

CC2530 ADC calc

Other Parts Discussed in Thread: CC2530, Z-STACK, CC2538, CC2538-SW

HI,


Please help me i am using CC2530 ADC but not getting correct values after conversion. Please find attached files used in program and results found.

0257.ADC calc.xls

2110.ADC.c
#include <ioCC2530.h>
unsigned char data_H,data_L;
unsigned int x=0;

void uart()
{
  
CLKCONCMD = CLKCONSTA & 0xB8; //clock control
while(CLKCONSTA & 0x40);
PERCFG&=~0x01; //Alernative 1 selected for UART0 peripheral.
P0SEL |= 0x0C; //P0.2 and P0.3 peripheral mode enabled.`
U0CSR |= 0xC0; //UART mode selected for USART0.
U0UCR |= 0x00; //H/w flow control disabled
U0GCR |= 0x08;
U0BAUD = 0x3b; //Baud rate set to 9600 bps
}
void delay()
{
   for(unsigned int i =0;i<50000;i++);   //15msdelay
  for(unsigned int i =0;i<50000;i++);
}
int main()
{
 
   P0SEL |= 0x01;
   APCFG |= 0x01;             //Anable the analog i/p channel
   ADCCON2 = 0x30;         // enable the AVDD5 pin reference & 12 bit,AIN0 channel select
   ADCCON3 |= 0xB0;   
   ADCCON1 |= 0x3F;          //enable the start conversion sequence,start select & disable the random generators 
  while(!(ADCCON1 & 0x80)); //chech the eoc bit enable or not
   while(ADCCON1 & 0x40);   //check the any conversion is running or not
   ADCCON1 |= 0x40;          //enable the start conversion sequence,start select & disable the random generators 
   while(!(ADCCON1 & 0x80)); //chech the eoc bit enable or not
  data_H = ADCH;
  data_L = ADCL;
  uart(); 
  U0DBUF=0xAA; 
  while(!(U0CSR & 0x02));
 U0DBUF=(data_H & 0x0F); 
  while(!(U0CSR & 0x02));
  delay();
  U0DBUF= data_L;
  while(!(U0CSR & 0x02));  
  while(1);

}

  • Hi,

    I reviewed your code and I noticed several things that must be corrected.

    Please use as reference http://www.ti.com/lit/pdf/swru191

    First of all, as explained in 12.2.5 of the user's guide, you should not truncate the digits of the MSB, rather you should get all the 14 bits of the results (MSB --> 8 bits, LSB(7:2)) and then truncate the last two bits of the result, eliminating the two least significant bits of the 16 bit word MSB LSB(7:2) to get the effective 12 bit conversion of the result.

    In your code, it seems instead you are truncating the most significant bits.

    As mentioned also in 12.2.7 of the same guide, the reference clock system should be 32 Mhz using an external oscillator.

    While you are setting your clock configuration to be using an external 32 Mhz crystal and an internal 32 Khz RC OSC, in the clock status register you are checking if the internal 16 Mhz RC OSC is active.

    Also, I think selecting the system clock should be the first thing you do in your code, and not late when you are calling the uart() function to configure the pins as UART pins.

    I would encourage you to look at some reference code in Z-stack, for instance HAL_BOARD_INIT to learn how to properly configure system clock settings and the hal_adc.c module to see an implementation of the ADC driver.

    Thanks,

    TheDarkSide

  • Hi Dark Side ,

    I want to implement an Application that supports multiple profiling, That's Why I want to purchase CC2538 till now, I was using CC 2530 but due to its its constraint of not supporting multiple Profiling I need to switch to some other Version, So, I want to know CC2538 supports Multiple Profiling?,If yes then please let me know, As I have to purchase and start my development further]

    I have already sent you the friend request, and Mailed at technical support please let em know

    thanks & regards

    Manish

  • I agree with TheDarkSide.

    Please have a look at our foundation software offering, its open source and free to use on our devices. There is a wealth of information in there about how to get started using this device.

    http://www.ti.com/tool/cc2538-sw

    Regards,
    /TA

  • Manish Kumar, 

    I am not sure what "Multiple Profiling" mean. Please start a new thread, because if you just append yourself to a different thread like this we will likely not find your question.

    Regards,
    /TA

  • Hi,

    i responded to the original thread on multiple profile (http://e2e.ti.com/support/wireless_connectivity/f/158/t/251234.aspx)

    I apologize for the delay.

    As TA12012 suggests, please try not to append a different topic to an existing thread so the threads stay 'on topic'.

    I understand you have been doing this in the first place, as you correctly opened the post on "multiple profile" and I apologize again for the delay, however I wanted to clarify this for the sake of clarity for you and the entire community that we are trying to help in using our parts.

    Thanks,

    TheDarkSide