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.

MSP430f5438A ---> MSP430f5438

Other Parts Discussed in Thread: MSP430F5438, MSP430F5438A, MSP430F5529

Hello TI Team,

i am running program downloaded from the TI site, on MSP430f5438:

#include "msp430x54xA.h"

#include "hal_UCS.h"
#include "hal_PMM.h"
#include "hal_USB.h"

#define STATUS_PASS (1)
#define STATUS_FAIL (0)
#define USB_STRING_LEN (20)
#define V_ones (14)
#define V_tenths (16)
#define C_tens (3) // USB_string[3] = tens of deg C
#define C_ones (4) // USB_string[4] = ones of deg C
#define F_hundreds (9) // USB_string[9] = hundreds of deg F
#define F_tens (10) // USB_string[10] = tens of deg F
#define F_ones (11) // USB_string[11] = ones of deg F

/* 5xx functions / variables */
void halBoardInit(void);
void halADCInit(void);

/* USB functions / variables */
unsigned char format_temperature_string(unsigned int degrees, unsigned char c_or_f);
void format_voltage_string(unsigned int voltage);
char USB_string[USB_STRING_LEN] = "C: xx F: xxx, x.xV\n\r"; //e.g. - "C: 26 F: 072,"

volatile unsigned long temp_temp, temp_vcc;

void main(void)
{
volatile unsigned long IntDegC, IntDegF;
volatile unsigned long batt_voltage;
// ^ compiler will not optimize variables

WDTCTL = WDTPW+WDTHOLD; // Stop WDT

/* Initialize GPIO to minimum current consumption */
halBoardInit();
/* Initialize ADC12 & REF module to sample temperature */
halADCInit();

/* Initialize LFXT1 */
P7SEL |= BIT1+BIT0; // Enable crystal pins
LFXT_Start(XT1DRIVE_0);

while(1){
REFCTL0 |= REFON; // Enable internal reference
__delay_cycles(85); // Settling time for reference
ADC12CTL0 |= ADC12ENC+ADC12SC; // (Re)enable & trigger conversion

// Poll IFG until ADC12MEM1 loaded signifying sequence is complete
while(!(ADC12IFG & BIT1));

ADC12CTL0 &= ~ADC12ENC; // Disable conversions to configure REF
REFCTL0 &= ~REFON; // Disable internal reference
temp_temp = ADC12MEM0;
temp_vcc = ADC12MEM1;

// Temperature in Celsius
// ((A10/4096*2000mV) - 680mV)*(1/2.25mV) = (A10/4096*889) - 302
// = (A10 - 1391) * (889 / 4096)
IntDegC = ((temp_temp - 1391) * 889) / 4096;
format_temperature_string(IntDegC, 'C');

// Temperature in Fahrenheit
// Tf = (9/5)*Tc + 32
IntDegF = ((temp_temp - 1391) * 1600) / 4096 + 32;
format_temperature_string(IntDegF, 'F');
__no_operation(); // SET BREAKPOINT HERE

// Calculate voltage
// 10 * Batt voltage = 2.0V(A11/4096) * 2 * 10 = 40(A11)/4096
batt_voltage = (temp_vcc * 40) >> 12;
format_voltage_string(batt_voltage);
__no_operation();

/* Initialize serial communication module to send data over USB */
halUsbInit();
halUsbSendString(&USB_string[0],USB_STRING_LEN+2);
halUsbShutDown(); // Shut down USB to enter sleep mode

__delay_cycles(2200000); // Delay 2 seconds
}
}

void format_voltage_string(unsigned int voltage)
{
unsigned char ones = '0';
unsigned char tenths = '0';

while(voltage >= 10)
{
ones++;
voltage -= 10;
}
tenths += voltage;

USB_string[V_ones] = ones;
USB_string[V_tenths] = tenths;
}

unsigned char format_temperature_string(unsigned int degrees, unsigned char c_or_f)
{
unsigned char hundreds = '0'; // Init to '0' to code in ASCII
unsigned char tens = '0';
unsigned char ones = '0';
unsigned char status = STATUS_PASS;

while(degrees >= 100){ // Calculate hundreds' place
hundreds++;
degrees -= 100;
}
while(degrees >= 10){ // Calculate tens' place
tens++;
degrees -= 10;
}
ones += degrees; // Remainder is ones' place

switch(c_or_f)
{
case 'c':
case 'C':
USB_string[C_tens] = tens;
USB_string[C_ones] = ones;
break;
case 'f':
case 'F':
USB_string[F_hundreds] = hundreds;
USB_string[F_tens] = tens;
USB_string[F_ones] = ones;
break;
default:
status = STATUS_FAIL; // Invalid parameter
break;
}
return status;
}

void halBoardInit(void)
{
// Tie unused ports
PAOUT = 0; PADIR = 0xFFFF; PASEL = 0;
PBOUT = 0; PBDIR = 0xFFFF; PBSEL = 0;
PCOUT = 0; PCDIR = 0xFFFF; PCSEL = 0;
PDOUT = 0; PDDIR = 0xFFFF; PDSEL = 0;
// P10.0 to USB RST pin, if enabled with J5
PEOUT = 0; PEDIR = 0xFEFF; PESEL = 0;
P11OUT = 0; P11DIR = 0xFF; P11SEL = 0;
PJOUT = 0; PJDIR = 0xFF;

P6OUT = 0x40; // Shut down audio output amp
P5DIR &= ~0x80; // USB RX Pin, Input with
// ...pulled down Resistor
P5OUT &= ~0x80;
P5REN |= 0x80;
}


void halADCInit(void){
// 5.4MHz (MODOSC_max) * 30 us (t_sensor)= 162 cycles min sampling time
ADC12CTL0 = ADC12SHT0_7 + ADC12ON+ADC12MSC; // Set sample time to 192 cycles
ADC12CTL1 = ADC12CONSEQ_1+ADC12SHP; // Enable sequence-of-channels & sample timer
ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_10; // ADC input ch A10 => temp sense
ADC12MCTL1 = ADC12SREF_1 + ADC12INCH_11 + ADC12EOS; // ADC input ch A11 => Vcc

/* Initialize the shared reference module */
REFCTL0 |= REFMSTR + REFVSEL_1; // Configure internal 2.0V reference
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------

If I run with msp430f5438A compiler it gives me not target. 

and when I compiled it with msp430f5438 compiler, It prints the error:


**** Build of configuration Lab 3 for project Lab_3 ****

"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
'Building target: Lab_3.out'
'Invoking: MSP430 Linker'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/bin/cl430" -vmspx --abi=coffabi --data_model=restricted --use_hw_mpy=F5 -g --define=__MSP430F5529__ --define=__MSP430F5438__ --undefine=__MSP430F5438A__ --diag_warning=225 --silicon_errata=CPU15 --silicon_errata=CPU18 --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=minimal -z -m"Lab_3.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv6/ccs_base/msp430/include" -i"C:/ti/ccsv6/msp430/include" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/include" -i"C:/ti/ccsv6/ccs_base/msp430/lib/5xx_6xx_FRxx" --reread_libs --warn_sections --xml_link_info="Lab_3_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "Lab_3.out" "./Lab_3_soln.obj" "./5xx_HAL/hal_UCS.obj" "./5xx_HAL/hal_pmm.obj" "./5xx_HAL/hal_usb.obj" "../lnk_msp430f5438.cmd" -l"libmath.a" -l"libc.a"
<Linking>
warning: could not resolve index library "libmath.a" to a compatible library

undefined first referenced
symbol in file
--------- ----------------
REFCTL0 ./Lab_3_soln.obj

error: unresolved symbols remain
error: errors encountered during linking; "Lab_3.out" not built

>> Compilation failure
gmake: *** [Lab_3.out] Error 1
gmake: Target `all' not remade because of errors.

**** Build Finished ****

--------------------------------------------------------------------------------------------------------------------

When I changed the header file to #include<msp430f5438.h>

it prints the error: 


**** Build of configuration Lab 3 for project Lab_3 ****

"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
'Building file: ../Lab_3_soln.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/bin/cl430" -vmspx --abi=coffabi --data_model=restricted --use_hw_mpy=F5 --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/msp430/include" --include_path="C:/5xx_ODW/Lab_3/5xx_HAL/" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.3/include" -g --define=__MSP430F5529__ --define=__MSP430F5438__ --undefine=__MSP430F5438A__ --diag_warning=225 --silicon_errata=CPU15 --silicon_errata=CPU18 --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=minimal --preproc_with_compile --preproc_dependency="Lab_3_soln.pp" "../Lab_3_soln.c"
"../Lab_3_soln.c", line 58: error: identifier "REFCTL0" is undefined
"../Lab_3_soln.c", line 58: error: identifier "REFON" is undefined
"../Lab_3_soln.c", line 178: error: identifier "REFCTL0" is undefined
"../Lab_3_soln.c", line 178: error: identifier "REFMSTR" is undefined
"../Lab_3_soln.c", line 178: error: identifier "REFVSEL_1" is undefined
5 errors detected in the compilation of "../Lab_3_soln.c".

>> Compilation failure
gmake: *** [Lab_3_soln.obj] Error 1
gmake: Target `all' not remade because of errors.

**** Build Finished ****

-------------------------------------------------------------------------------------------

I did not understand, how to run this program on MSP430f5438, CCS6.

Please let me know what settings i need to change, or if is there any mistake in code.

Thanks

  • Nitish,

    The MSP430F5438 does not have a shared reference section in its include file like the MSP430F5438A, hence why you are receiving the undefined REFCTL0 identifier errors. You must instead set the reference in the ADC12 registers themselves. So remove the two lines where REFCTL0 is mentioned and add ADC12REFON to the ADC12CTL0 module. Also note that the MSP430F5438 does not support REFMSTR mode.

    Be warned that TI does not recommend using the MSP430F5438 part in a new design and that it continues to be in production to support existing customers. The recommended replacement part is the MSP430F5438A.

    Regards,
    Ryan

**Attention** This is a public forum