Hai,
In ccs5.5 code not compiling .I get this code from http://dbindner.freeshell.org/msp430/adc_g2553.html
and edited a little.here is the code please point out the problem.
Is it possible to use itoa in ccs and stdlib.h or string.h like c headder files?
#include "msp430g2553.h"
//#include <string.h>
//#include <stdlib.h>
char hello[] = " \r\n \r\n \r\n \r\n \r\n \r\n";
int tx_count = 0;
//unsigned int adc_result[6];
unsigned int adc_result[6] = { 7, 8, 9, 10, 11, 12 };
void uart_init( void ) {
/**
* 1. Set UCSWRST
* 2. Initialize all USCI registers
* 3. Configure ports
* 4. Clear UCSWRST
* 5. Enable interrupts via UCxRXIE and/or UCxTXIE
*/
// (1) Set state machine to the reset state
UCA0CTL1 = UCSWRST;
// (2) Initialize USCI registers
UCA0CTL1 |= UCSSEL_2; // CLK = SMCLK
UCA0BR0 = 104; // 1MHz/9600 =104
UCA0BR1 = 0x00; // from User Guide table 15-4
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
// (3) Configure ports
P1SEL = BIT1 + BIT2; // P1.1 = RXD, P1.2=TXD
P1SEL2= BIT1 + BIT2; // P1.1 = RXD, P1.2=TXD
// (4) Clear UCSWRST flag
UCA0CTL1 &= ~UCSWRST; // Initialize USCI state machine
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog timer
// UART settings depend on an accurate 1 MHz clock.
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
P1DIR &= ~BIT3; // Set P1.3 to input pin
P1IE |= BIT3; // P1.3 (S2) triggers an interrupt
P1IES |= BIT3; // on falling edge
// Initialize the UART
uart_init();
// Initialize the ADC10 using
// 2.5V reference, 16 clocks, on, multiple samples
ADC10CTL0 = SREF_1 | REF2_5V | REFON | ADC10SHT_2 | ADC10ON | MSC;
// input channel 5, trigger on ADC10SC bit, no clock division,
// internal ADC clock, sequence of conversions counting down from A5
ADC10CTL1 = INCH_5 | SHS_0 | ADC10DIV_0 | ADC10SSEL_0 | CONSEQ_1;
// We want samples of A5, A4, A3, and A0 but you have to take all 6.
ADC10DTC1 = 6;
// This is a funny register. It's called "analog enable" but really
// what it does is "digital disable". You can always sample from a pin,
// and this doesn't change that. What it does is disconnect any digital
// activity from the pin, so it can only work for ADC. Saves power.
ADC10AE0 = BIT5 + BIT4 + BIT0; // (all but A3 which we need for switch S2)
// Go to sleep. We'll do an ADC and send data when the switch S2 is pressed.
while( 1 ) {
__bis_SR_register( LPM3_bits + GIE );
ADC10SA = (unsigned int)adc_result; // destination address for DMA
ADC10CTL0 |= ENC + ADC10SC; // trigger the conversion
while( ADC10CTL1 & ADC10BUSY ) ;
itoa(adc_result[5], hello, 10 ); // convert A0 to a string
itoa(adc_result[4], hello+7, 10 ); // convert A1 to a string
itoa(adc_result[3], hello+14, 10 ); // convert A2 to a string
itoa(adc_result[2], hello+21, 10 ); // convert A3 to a string
itoa(adc_result[1], hello+28, 10 ); // convert A4 to a string
itoa(adc_result[0], hello+35, 10 ); // convert A5 to a string
IE2 |= UCA0TXIE; // enable interrupts to start the UART
}
}
// Switch S2 was pressed. Get things started.
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
int i, j;
P1IFG &= ~BIT3; // clear interrupt flag
P1IE &= ~BIT3; // disable this button
// blank out any previous values
for( i = 0; i < 6 ; i++ )
for( j = 0; j < 5; j++ )
hello[i*7 + j] = ' ';
__bic_SR_register_on_exit( LPM3_bits ); // wake up main program
}
// This routine does the sending. An interrupt is triggered each time
// the UART is ready to transmit the next character.
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
UCA0TXBUF = hello[ tx_count++ ]; // Load the next character
// and increment the count.
// After the 15 characters of the message are sent, we're done.
if( tx_count >= 15 )
{
IE2 &= ~UCA0TXIE; // disable this routine so it won't be called again
P1IE |= BIT3; // re-enable the S2 switch interrupt
tx_count = 0; // reset the count for the next transmission
}
}
////////////////////////////////////////
the problems encountered
#10010 errors encountered during linking; "tesadc.out" not built tesadc C/C++ Problem
<a href="file:/C:/ti/ccsv5/tools/compiler/dmed/HTML/10234.html">#10234-D</a> unresolved symbols remain tesadc C/C++ Problem
unresolved symbol itoa, first referenced in ./main.obj tesadc C/C++ Problem
<a href="file:/C:/ti/ccsv5/tools/compiler/dmed/HTML/225.html">#225-D</a> function "itoa" declared implicitly main.c /tesadc line 77 C/C++ Problem