Maker Pro
Maker Pro

Problem with Code Composer for TI MSP430

ajmartin01

Feb 19, 2023
4
Joined
Feb 19, 2023
Messages
4
I just started using the MSP430 series micro-controller, using TI code composer as the IDE. Simple programs work fine "blink, toggle and stuff" But if I try to use anything involving timing I get F_CPU undefined error. here is a small piece of code that gets 2 errors.


# define F_CPU 1000000UL
# include <util/delay.h>
# include <mps430>
int Control = 0;

int main(void) {

/*** Watchdog timer and clock Set-Up ***/
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
DCOCTL = 0; // Select lowest DCOx and MODx
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation

and the errors:
line 11: error #20: identifier "F_CPU" is undefined
line 15: error #20: identifier "DC0CTL" is undefined

Really new to the MPS environment, I think I may need to set something somewhere in the project or compiler but I cant find any thing. Any ideas?

Alan
 

Delta Prime

Jul 29, 2020
231
Joined
Jul 29, 2020
Messages
231
Hello there! :) // delay.h - delay library providing MSP430 delay macros and functions. These
// are for convenience and shouldn't be considered 100% accurate, especially if
// timing is important. For the most accurate delays, make sure F_CPU matches
// the operating frequency of your MSP430 device.
// F_CPU should be defined to the frequency to base delays upon before sourcing
// the delay library as follows:
// Example for 16MHz
// #define F_CPU 16000000UL
// Example for 25MHz
// #define F_CPU 25000000UL

 

ajmartin01

Feb 19, 2023
4
Joined
Feb 19, 2023
Messages
4
Hello there! :) // delay.h - delay library providing MSP430 delay macros and functions. These
// are for convenience and shouldn't be considered 100% accurate, especially if
// timing is important. For the most accurate delays, make sure F_CPU matches
// the operating frequency of your MSP430 device.
// F_CPU should be defined to the frequency to base delays upon before sourcing
// the delay library as follows:
// Example for 16MHz
// #define F_CPU 16000000UL
// Example for 25MHz
// #define F_CPU 25000000UL

Thank you for your answer. Hoping you know this processor and code composer. Are you saying if my assumption of the F_CPU frequency is nor correct, I will get an F-CPU undefined error? That makes little sense to me as an error message since it seems to be defined. In the Atmel world with codevision it would at least compile , but your results would be not as expected. Oh, Just noticed if I do not include the delay.h file I get the same message. Both of these seem to be defined?
line 11: error #20: identifier "F_CPU" is undefined
line 15: error #20: identifier "DC0CTL" is undefined
 
Top