EmbeddedRelated.com
Forums

CCS 4 question

Started by FIRAT KOCAK January 30, 2011
Hi,

I am a newbie to Msp430 and CCS. I installed CCS 4 and trying to learn
some coding Msp430 Launchpad. I modified original Launchpad code ( in
fact removed almost all code just adding led pins update in a loop ). My
code is so simple and includes a few line codes.

My problem is, i successfully build the project and start debugger and i
am able to execute the code step by step. It works as expected. But
after closing the debugger and resetting the board( simply remove the
usb cable and then reconnect it ) leds are always lit. My code is below

#include "msp430x20x2.h"

#define LED0 BIT0
#define LED1 BIT6
#define LED_DIR P1DIR
#define LED_OUT P1OUT

#define BUTTON BIT3
#define BUTTON_OUT P1OUT
#define BUTTON_DIR P1DIR
#define BUTTON_IN P1IN
#define BUTTON_IE P1IE
#define BUTTON_IES P1IES
#define BUTTON_IFG P1IFG
#define BUTTON_REN P1REN

#define TXD BIT1 // TXD on P1.1
#define RXD BIT2 // RXD on P1.2

#define APP_STANDBY_MODE 0
#define APP_APPLICATION_MODE 1

#define TIMER_PWM_MODE 0
#define TIMER_UART_MODE 1
#define TIMER_PWM_PERIOD 2000
#define TIMER_PWM_OFFSET 20

#define TEMP_SAME 0
#define TEMP_HOT 1
#define TEMP_COLD 2

#define TEMP_THRESHOLD 5

// Conditions for 9600/4$00 Baud SW UART, SMCLK = 1MHz
#define Bitime_5 0x05*4 // ~ 0.5
bit length + small adjustment
#define Bitime 13*4//0x0D

#define UART_UPDATE_INTERVAL 1000
unsigned char BitCnt;
unsigned char applicationMode = APP_STANDBY_MODE;
unsigned char timerMode = TIMER_PWM_MODE;

unsigned char tempMode;
unsigned char calibrateUpdate = 0;
unsigned char tempPolarity = TEMP_SAME;
unsigned int TXByte;

/* Using an 8-value moving average filter on sampled ADC values */
long tempMeasured[8];
unsigned char tempMeasuredPosition=0;
long tempAverage;

long tempCalibrated, tempDifference;

void InitializeLeds(void);
void InitializeButton(void);
void InitializeClocks(void);

void InitializeClocks(void)
{

BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ;
BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO / 8 = 1MHz
}

void InitializeButton(void) // Configure Push Button
{
BUTTON_DIR &= ~BUTTON;
BUTTON_OUT |= BUTTON;
BUTTON_REN |= BUTTON;
BUTTON_IES |= BUTTON;
BUTTON_IFG &= ~BUTTON;
BUTTON_IE |= BUTTON;
}
void InitializeLeds(void)
{
LED_DIR |= LED0 + LED1;
LED_OUT &= ~(LED0 + LED1);
}

void Delay( int dcount )
{
int iz;

for( iz = 0; iz < dcount; iz ++ ){}
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT

InitializeClocks();
InitializeLeds();

while( 1 )
{
LED_OUT &= ~( LED0 + LED1 );
Delay( 10000 );
LED_OUT |= ( LED0 + LED1 );
Delay( 10000 );
}

}
Changing the delay count does not help. Changing build type from debug
to release does not help. Probably i forget or miss something but i
could not find out it.

Any help is appreciated.
Best regards,

Firat


Beginning Microcontrollers with the MSP430

--- In m..., FIRAT KOCAK wrote:
>
> Hi,
>
> I am a newbie to Msp430 and CCS. I installed CCS 4 and trying to learn
> some coding Msp430 Launchpad. I modified original Launchpad code ( in
> fact removed almost all code just adding led pins update in a loop ). My
> code is so simple and includes a few line codes.
>
> My problem is, i successfully build the project and start debugger and i
> am able to execute the code step by step. It works as expected. But
> after closing the debugger and resetting the board( simply remove the
> usb cable and then reconnect it ) leds are always lit. My code is below
>
> #include "msp430x20x2.h"
>
> #define LED0 BIT0
> #define LED1 BIT6
> #define LED_DIR P1DIR
> #define LED_OUT P1OUT
>
> #define BUTTON BIT3
> #define BUTTON_OUT P1OUT
> #define BUTTON_DIR P1DIR
> #define BUTTON_IN P1IN
> #define BUTTON_IE P1IE
> #define BUTTON_IES P1IES
> #define BUTTON_IFG P1IFG
> #define BUTTON_REN P1REN
>
> #define TXD BIT1 // TXD on P1.1
> #define RXD BIT2 // RXD on P1.2
>
> #define APP_STANDBY_MODE 0
> #define APP_APPLICATION_MODE 1
>
> #define TIMER_PWM_MODE 0
> #define TIMER_UART_MODE 1
> #define TIMER_PWM_PERIOD 2000
> #define TIMER_PWM_OFFSET 20
>
> #define TEMP_SAME 0
> #define TEMP_HOT 1
> #define TEMP_COLD 2
>
> #define TEMP_THRESHOLD 5
>
> // Conditions for 9600/4$00 Baud SW UART, SMCLK = 1MHz
> #define Bitime_5 0x05*4 // ~ 0.5
> bit length + small adjustment
> #define Bitime 13*4//0x0D
>
> #define UART_UPDATE_INTERVAL 1000
> unsigned char BitCnt;
> unsigned char applicationMode = APP_STANDBY_MODE;
> unsigned char timerMode = TIMER_PWM_MODE;
>
> unsigned char tempMode;
> unsigned char calibrateUpdate = 0;
> unsigned char tempPolarity = TEMP_SAME;
> unsigned int TXByte;
>
> /* Using an 8-value moving average filter on sampled ADC values */
> long tempMeasured[8];
> unsigned char tempMeasuredPosition=0;
> long tempAverage;
>
> long tempCalibrated, tempDifference;
>
> void InitializeLeds(void);
> void InitializeButton(void);
> void InitializeClocks(void);
>
> void InitializeClocks(void)
> {
>
> BCSCTL1 = CALBC1_1MHZ; // Set range
> DCOCTL = CALDCO_1MHZ;
> BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO / 8 = 1MHz
> }
>
> void InitializeButton(void) // Configure Push Button
> {
> BUTTON_DIR &= ~BUTTON;
> BUTTON_OUT |= BUTTON;
> BUTTON_REN |= BUTTON;
> BUTTON_IES |= BUTTON;
> BUTTON_IFG &= ~BUTTON;
> BUTTON_IE |= BUTTON;
> }
> void InitializeLeds(void)
> {
> LED_DIR |= LED0 + LED1;
> LED_OUT &= ~(LED0 + LED1);
> }
>
> void Delay( int dcount )
> {
> int iz;
>
> for( iz = 0; iz < dcount; iz ++ ){}
> }
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
>
> InitializeClocks();
> InitializeLeds();
>
> while( 1 )
> {
> LED_OUT &= ~( LED0 + LED1 );
> Delay( 10000 );
> LED_OUT |= ( LED0 + LED1 );
> Delay( 10000 );
> }
>
> }
> Changing the delay count does not help. Changing build type from debug
> to release does not help. Probably i forget or miss something but i
> could not find out it.
>
> Any help is appreciated.
> Best regards,
>
> Firat
>
>

Just glancing at your code it appears you're running at 1MHz, and I suspect your delay is not quite as long as you think...
I suspect your LEDs are blinking faster than you can see.

Hi Bob,

I changed delay counter from 10.000 to 500.000 but nothing changed.

Thanks,

Firat

On 30.01.2011 23:05, Bob wrote:
>
> --- In m... , FIRAT
> KOCAK wrote:
> >
> > Hi,
> >
> > I am a newbie to Msp430 and CCS. I installed CCS 4 and trying to learn
> > some coding Msp430 Launchpad. I modified original Launchpad code ( in
> > fact removed almost all code just adding led pins update in a loop
> ). My
> > code is so simple and includes a few line codes.
> >
> > My problem is, i successfully build the project and start debugger
> and i
> > am able to execute the code step by step. It works as expected. But
> > after closing the debugger and resetting the board( simply remove the
> > usb cable and then reconnect it ) leds are always lit. My code is below
> >
> > #include "msp430x20x2.h"
> >
> > #define LED0 BIT0
> > #define LED1 BIT6
> > #define LED_DIR P1DIR
> > #define LED_OUT P1OUT
> >
> >
> >
> > #define BUTTON BIT3
> > #define BUTTON_OUT P1OUT
> > #define BUTTON_DIR P1DIR
> > #define BUTTON_IN P1IN
> > #define BUTTON_IE P1IE
> > #define BUTTON_IES P1IES
> > #define BUTTON_IFG P1IFG
> > #define BUTTON_REN P1REN
> >
> > #define TXD BIT1 // TXD on P1.1
> > #define RXD BIT2 // RXD on P1.2
> >
> > #define APP_STANDBY_MODE 0
> > #define APP_APPLICATION_MODE 1
> >
> > #define TIMER_PWM_MODE 0
> > #define TIMER_UART_MODE 1
> > #define TIMER_PWM_PERIOD 2000
> > #define TIMER_PWM_OFFSET 20
> >
> > #define TEMP_SAME 0
> > #define TEMP_HOT 1
> > #define TEMP_COLD 2
> >
> > #define TEMP_THRESHOLD 5
> >
> > // Conditions for 9600/4$00 Baud SW UART, SMCLK = 1MHz
> > #define Bitime_5 0x05*4 // ~ 0.5
> > bit length + small adjustment
> > #define Bitime 13*4//0x0D
> >
> > #define UART_UPDATE_INTERVAL 1000
> >
> >
> > unsigned char BitCnt;
> >
> >
> > unsigned char applicationMode = APP_STANDBY_MODE;
> > unsigned char timerMode = TIMER_PWM_MODE;
> >
> > unsigned char tempMode;
> > unsigned char calibrateUpdate = 0;
> > unsigned char tempPolarity = TEMP_SAME;
> > unsigned int TXByte;
> >
> > /* Using an 8-value moving average filter on sampled ADC values */
> > long tempMeasured[8];
> > unsigned char tempMeasuredPosition=0;
> > long tempAverage;
> >
> > long tempCalibrated, tempDifference;
> >
> >
> >
> > void InitializeLeds(void);
> > void InitializeButton(void);
> > void InitializeClocks(void);
> >
> > void InitializeClocks(void)
> > {
> >
> > BCSCTL1 = CALBC1_1MHZ; // Set range
> > DCOCTL = CALDCO_1MHZ;
> > BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO / 8 = 1MHz
> > }
> >
> > void InitializeButton(void) // Configure Push Button
> > {
> > BUTTON_DIR &= ~BUTTON;
> > BUTTON_OUT |= BUTTON;
> > BUTTON_REN |= BUTTON;
> > BUTTON_IES |= BUTTON;
> > BUTTON_IFG &= ~BUTTON;
> > BUTTON_IE |= BUTTON;
> > }
> >
> >
> > void InitializeLeds(void)
> > {
> > LED_DIR |= LED0 + LED1;
> > LED_OUT &= ~(LED0 + LED1);
> > }
> >
> > void Delay( int dcount )
> > {
> > int iz;
> >
> > for( iz = 0; iz < dcount; iz ++ ){}
> > }
> >
> >
> > void main(void)
> > {
> > WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> >
> > InitializeClocks();
> > InitializeLeds();
> >
> > while( 1 )
> > {
> > LED_OUT &= ~( LED0 + LED1 );
> > Delay( 10000 );
> > LED_OUT |= ( LED0 + LED1 );
> > Delay( 10000 );
> > }
> >
> > }
> >
> >
> > Changing the delay count does not help. Changing build type from debug
> > to release does not help. Probably i forget or miss something but i
> > could not find out it.
> >
> > Any help is appreciated.
> >
> >
> > Best regards,
> >
> > Firat
> >
> >
> >
> > Just glancing at your code it appears you're running at 1MHz, and I
> suspect your delay is not quite as long as you think...
> I suspect your LEDs are blinking faster than you can see.



Well, your code uses 10000 as an int. So, if you mean you increased your delay to 500000, you might need to take a moment and review what the largest value you can stuff into a 16 bit integer...

Also, I might suggest that adding a function call for your delay inside your main's while-loop is probably not the most efficient coding practice in an msp430 environment. Finally, delays of the type you are using are also dependent on clock/processor speeds and inherently risky...

bob

--- In m..., FIRAT KOCAK wrote:
>
> Hi Bob,
>
> I changed delay counter from 10.000 to 500.000 but nothing changed.
>
> Thanks,
>
> Firat
>
> On 30.01.2011 23:05, Bob wrote:
> >
> > --- In m... , FIRAT
> > KOCAK wrote:
> > >
> > > Hi,
> > >
> > > I am a newbie to Msp430 and CCS. I installed CCS 4 and trying to learn
> > > some coding Msp430 Launchpad. I modified original Launchpad code ( in
> > > fact removed almost all code just adding led pins update in a loop
> > ). My
> > > code is so simple and includes a few line codes.
> > >
> > > My problem is, i successfully build the project and start debugger
> > and i
> > > am able to execute the code step by step. It works as expected. But
> > > after closing the debugger and resetting the board( simply remove the
> > > usb cable and then reconnect it ) leds are always lit. My code is below
> > >
> > > #include "msp430x20x2.h"
> > >
> > > #define LED0 BIT0
> > > #define LED1 BIT6
> > > #define LED_DIR P1DIR
> > > #define LED_OUT P1OUT
> > >
> > >
> > >
> > > #define BUTTON BIT3
> > > #define BUTTON_OUT P1OUT
> > > #define BUTTON_DIR P1DIR
> > > #define BUTTON_IN P1IN
> > > #define BUTTON_IE P1IE
> > > #define BUTTON_IES P1IES
> > > #define BUTTON_IFG P1IFG
> > > #define BUTTON_REN P1REN
> > >
> > > #define TXD BIT1 // TXD on P1.1
> > > #define RXD BIT2 // RXD on P1.2
> > >
> > > #define APP_STANDBY_MODE 0
> > > #define APP_APPLICATION_MODE 1
> > >
> > > #define TIMER_PWM_MODE 0
> > > #define TIMER_UART_MODE 1
> > > #define TIMER_PWM_PERIOD 2000
> > > #define TIMER_PWM_OFFSET 20
> > >
> > > #define TEMP_SAME 0
> > > #define TEMP_HOT 1
> > > #define TEMP_COLD 2
> > >
> > > #define TEMP_THRESHOLD 5
> > >
> > > // Conditions for 9600/4$00 Baud SW UART, SMCLK = 1MHz
> > > #define Bitime_5 0x05*4 // ~ 0.5
> > > bit length + small adjustment
> > > #define Bitime 13*4//0x0D
> > >
> > > #define UART_UPDATE_INTERVAL 1000
> > >
> > >
> > > unsigned char BitCnt;
> > >
> > >
> > > unsigned char applicationMode = APP_STANDBY_MODE;
> > > unsigned char timerMode = TIMER_PWM_MODE;
> > >
> > > unsigned char tempMode;
> > > unsigned char calibrateUpdate = 0;
> > > unsigned char tempPolarity = TEMP_SAME;
> > > unsigned int TXByte;
> > >
> > > /* Using an 8-value moving average filter on sampled ADC values */
> > > long tempMeasured[8];
> > > unsigned char tempMeasuredPosition=0;
> > > long tempAverage;
> > >
> > > long tempCalibrated, tempDifference;
> > >
> > >
> > >
> > > void InitializeLeds(void);
> > > void InitializeButton(void);
> > > void InitializeClocks(void);
> > >
> > > void InitializeClocks(void)
> > > {
> > >
> > > BCSCTL1 = CALBC1_1MHZ; // Set range
> > > DCOCTL = CALDCO_1MHZ;
> > > BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO / 8 = 1MHz
> > > }
> > >
> > > void InitializeButton(void) // Configure Push Button
> > > {
> > > BUTTON_DIR &= ~BUTTON;
> > > BUTTON_OUT |= BUTTON;
> > > BUTTON_REN |= BUTTON;
> > > BUTTON_IES |= BUTTON;
> > > BUTTON_IFG &= ~BUTTON;
> > > BUTTON_IE |= BUTTON;
> > > }
> > >
> > >
> > > void InitializeLeds(void)
> > > {
> > > LED_DIR |= LED0 + LED1;
> > > LED_OUT &= ~(LED0 + LED1);
> > > }
> > >
> > > void Delay( int dcount )
> > > {
> > > int iz;
> > >
> > > for( iz = 0; iz < dcount; iz ++ ){}
> > > }
> > >
> > >
> > > void main(void)
> > > {
> > > WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> > >
> > > InitializeClocks();
> > > InitializeLeds();
> > >
> > > while( 1 )
> > > {
> > > LED_OUT &= ~( LED0 + LED1 );
> > > Delay( 10000 );
> > > LED_OUT |= ( LED0 + LED1 );
> > > Delay( 10000 );
> > > }
> > >
> > > }
> > >
> > >
> > > Changing the delay count does not help. Changing build type from debug
> > > to release does not help. Probably i forget or miss something but i
> > > could not find out it.
> > >
> > > Any help is appreciated.
> > >
> > >
> > > Best regards,
> > >
> > > Firat
> > >
> > >
> > >
> > >
> >
> > Just glancing at your code it appears you're running at 1MHz, and I
> > suspect your delay is not quite as long as you think...
> > I suspect your LEDs are blinking faster than you can see.
> >
> >
>

On 30.01.2011 23:41, Bob wrote:
>
> Well, your code uses 10000 as an int. So, if you mean you increased
> your delay to 500000, you might need to take a moment and review what
> the largest value you can stuff into a 16 bit integer...
>

I know this, bob. I am an old programmer, just new to MSP430 and CCS. I
changed int to long before building.
> Also, I might suggest that adding a function call for your delay
> inside your main's while-loop is probably not the most efficient
> coding practice in an msp430 environment. Finally, delays of the type
> you are using are also dependent on clock/processor speeds and
> inherently risky...
>

Since i am just experiencing the new environment, i wanted to make the
loop part simple. But no problem, i will add the loop function code
into the loop itself and let you know if anything changed.

Firat

>
> bob
>
> --- In m... , FIRAT
> KOCAK wrote:
> >
> > Hi Bob,
> >
> > I changed delay counter from 10.000 to 500.000 but nothing changed.
> >
> > Thanks,
> >
> > Firat
> >
> > On 30.01.2011 23:05, Bob wrote:
> > >
> > > --- In m...
> , FIRAT
> > > KOCAK wrote:
> > > >
> > > > Hi,
> > > >
> > > > I am a newbie to Msp430 and CCS. I installed CCS 4 and trying to
> learn
> > > > some coding Msp430 Launchpad. I modified original Launchpad code
> ( in
> > > > fact removed almost all code just adding led pins update in a loop
> > > ). My
> > > > code is so simple and includes a few line codes.
> > > >
> > > > My problem is, i successfully build the project and start debugger
> > > and i
> > > > am able to execute the code step by step. It works as expected. But
> > > > after closing the debugger and resetting the board( simply
> remove the
> > > > usb cable and then reconnect it ) leds are always lit. My code
> is below
> > > >
> > > > #include "msp430x20x2.h"
> > > >
> > > > #define LED0 BIT0
> > > > #define LED1 BIT6
> > > > #define LED_DIR P1DIR
> > > > #define LED_OUT P1OUT
> > > >
> > > >
> > > >
> > > > #define BUTTON BIT3
> > > > #define BUTTON_OUT P1OUT
> > > > #define BUTTON_DIR P1DIR
> > > > #define BUTTON_IN P1IN
> > > > #define BUTTON_IE P1IE
> > > > #define BUTTON_IES P1IES
> > > > #define BUTTON_IFG P1IFG
> > > > #define BUTTON_REN P1REN
> > > >
> > > > #define TXD BIT1 // TXD on P1.1
> > > > #define RXD BIT2 // RXD on P1.2
> > > >
> > > > #define APP_STANDBY_MODE 0
> > > > #define APP_APPLICATION_MODE 1
> > > >
> > > > #define TIMER_PWM_MODE 0
> > > > #define TIMER_UART_MODE 1
> > > > #define TIMER_PWM_PERIOD 2000
> > > > #define TIMER_PWM_OFFSET 20
> > > >
> > > > #define TEMP_SAME 0
> > > > #define TEMP_HOT 1
> > > > #define TEMP_COLD 2
> > > >
> > > > #define TEMP_THRESHOLD 5
> > > >
> > > > // Conditions for 9600/4$00 Baud SW UART, SMCLK = 1MHz
> > > > #define Bitime_5 0x05*4 // ~ 0.5
> > > > bit length + small adjustment
> > > > #define Bitime 13*4//0x0D
> > > >
> > > > #define UART_UPDATE_INTERVAL 1000
> > > >
> > > >
> > > > unsigned char BitCnt;
> > > >
> > > >
> > > > unsigned char applicationMode = APP_STANDBY_MODE;
> > > > unsigned char timerMode = TIMER_PWM_MODE;
> > > >
> > > > unsigned char tempMode;
> > > > unsigned char calibrateUpdate = 0;
> > > > unsigned char tempPolarity = TEMP_SAME;
> > > > unsigned int TXByte;
> > > >
> > > > /* Using an 8-value moving average filter on sampled ADC values */
> > > > long tempMeasured[8];
> > > > unsigned char tempMeasuredPosition=0;
> > > > long tempAverage;
> > > >
> > > > long tempCalibrated, tempDifference;
> > > >
> > > >
> > > >
> > > > void InitializeLeds(void);
> > > > void InitializeButton(void);
> > > > void InitializeClocks(void);
> > > >
> > > > void InitializeClocks(void)
> > > > {
> > > >
> > > > BCSCTL1 = CALBC1_1MHZ; // Set range
> > > > DCOCTL = CALDCO_1MHZ;
> > > > BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO / 8 = 1MHz
> > > > }
> > > >
> > > > void InitializeButton(void) // Configure Push Button
> > > > {
> > > > BUTTON_DIR &= ~BUTTON;
> > > > BUTTON_OUT |= BUTTON;
> > > > BUTTON_REN |= BUTTON;
> > > > BUTTON_IES |= BUTTON;
> > > > BUTTON_IFG &= ~BUTTON;
> > > > BUTTON_IE |= BUTTON;
> > > > }
> > > >
> > > >
> > > > void InitializeLeds(void)
> > > > {
> > > > LED_DIR |= LED0 + LED1;
> > > > LED_OUT &= ~(LED0 + LED1);
> > > > }
> > > >
> > > > void Delay( int dcount )
> > > > {
> > > > int iz;
> > > >
> > > > for( iz = 0; iz < dcount; iz ++ ){}
> > > > }
> > > >
> > > >
> > > > void main(void)
> > > > {
> > > > WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> > > >
> > > > InitializeClocks();
> > > > InitializeLeds();
> > > >
> > > > while( 1 )
> > > > {
> > > > LED_OUT &= ~( LED0 + LED1 );
> > > > Delay( 10000 );
> > > > LED_OUT |= ( LED0 + LED1 );
> > > > Delay( 10000 );
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > > Changing the delay count does not help. Changing build type from
> debug
> > > > to release does not help. Probably i forget or miss something but i
> > > > could not find out it.
> > > >
> > > > Any help is appreciated.
> > > >
> > > >
> > > > Best regards,
> > > >
> > > > Firat
> > > >
> > > >
> > > >
> > > >
> > >
> > > Just glancing at your code it appears you're running at 1MHz, and I
> > > suspect your delay is not quite as long as you think...
> > > I suspect your LEDs are blinking faster than you can see.
> > >
> > >
> >
> >
> >
> >
> >



FIRAT KOCAK wrote:
> Hi Bob,
>
> I changed delay counter from 10.000 to 500.000 but nothing changed.
>

A couple of things. You must have set the micro to run while
debugging..? Did it Blink then? You should have gotten a warning with
500,000 as int16_t is 32767 max. Did you recompile? (I don't use CCS
enough to recall how it enforces...)

But, for the debug info in the linker output, debug or release should
not matter. In fact, there is no good reason for release builds with
micros, IMHO. There is no debug info in the target's code with debug. It
should be exactly the same code.

The only catch would be if CCS silently switch optimization on you. If
it does, don't ever go down that road...

But start with you can see the blinks with break points and without
stopping the session, run without the breakpoints and work from there.
Watch if the leds dim, then you have what Bob pointed out. If they don't
dim, break in and see what's going on.

Best, Dan.

On 30/01/11 20:53, FIRAT KOCAK wrote:
> Hi,
>
> I am a newbie to Msp430 and CCS. I installed CCS 4 and trying to learn
> some coding Msp430 Launchpad. I modified original Launchpad code ( in
> fact removed almost all code just adding led pins update in a loop ). My
> code is so simple and includes a few line codes.
>

If you are using CCS, I'd be sceptical of the compiler. Your code
doesn't yet make use of your global variables like "BitCnt", but be
aware that CCS does not initialise these to zero - in contradiction to
the C standards.

> void Delay( int dcount )
> {
> int iz;
>
> for( iz = 0; iz < dcount; iz ++ ){}
> }
>

You must declare "iz" to be volatile - if not, the compiler can remove
that loop entirely. It may well do so regardless of any optimisation
settings you may have picked.
Hi Dan,
On 30.01.2011 23:58, Dan Bloomquist wrote:
>
> FIRAT KOCAK wrote:
> > Hi Bob,
> >
> > I changed delay counter from 10.000 to 500.000 but nothing changed.
> > A couple of things. You must have set the micro to run while
> debugging..? Did it Blink then?
>
I checked it, no it didn't.

> You should have gotten a warning with
> 500,000 as int16_t is 32767 max. Did you recompile? (I don't use CCS
> enough to recall how it enforces...)
>

I know it, i changed the "int" as "long" before building.

>
> But, for the debug info in the linker output, debug or release should
> not matter. In fact, there is no good reason for release builds with
> micros, IMHO. There is no debug info in the target's code with debug. It
> should be exactly the same code.
>
> The only catch would be if CCS silently switch optimization on you. If
> it does, don't ever go down that road...
>

I don't know anything about this feature. But i will check the option
and correct it if i can find it.

>
> But start with you can see the blinks with break points and without
> stopping the session, run without the breakpoints and work from there.
>

I can see the leds are dimmed and lit while single stepping or placing
breakpoints but disabling the breakpoints and then pressing the run make
no change, leds are always lit.

> Watch if the leds dim, then you have what Bob pointed out. If they don't
> dim, break in and see what's going on.
>
> Best, Dan.
>

Thank you very much for the help.

Firat



Hi David,

Honestly, after i read your message i said, "huh, that is it!" . thank
you very much. The problem has now gone. It runs well. I had read about
the issue "volatile" in the past messages but i have never thought it
will happen to me :) I am still struggling to understand why compiler
removes a local variable even though it is in use ?

I think i need some time to better learn and read much about the
compiler behavior.

Thank you and thanks to Bob and Dan.

Firat

On 31.01.2011 00:24, David Brown wrote:
>
> On 30/01/11 20:53, FIRAT KOCAK wrote:
> > Hi,
> >
> > I am a newbie to Msp430 and CCS. I installed CCS 4 and trying to learn
> > some coding Msp430 Launchpad. I modified original Launchpad code ( in
> > fact removed almost all code just adding led pins update in a loop ). My
> > code is so simple and includes a few line codes.
> > If you are using CCS, I'd be sceptical of the compiler. Your code
> doesn't yet make use of your global variables like "BitCnt", but be
> aware that CCS does not initialise these to zero - in contradiction to
> the C standards.
>
> > void Delay( int dcount )
> > {
> > int iz;
> >
> > for( iz = 0; iz < dcount; iz ++ ){}
> > }
> > You must declare "iz" to be volatile - if not, the compiler can remove
> that loop entirely. It may well do so regardless of any optimisation
> settings you may have picked.



Some of your code may have vaporized because your variables are not volatile.

--- In m..., FIRAT KOCAK wrote:
>
> Hi,
>
> I am a newbie to Msp430 and CCS. I installed CCS 4 and trying to learn
> some coding Msp430 Launchpad. I modified original Launchpad code ( in
> fact removed almost all code just adding led pins update in a loop ). My
> code is so simple and includes a few line codes.
>
> My problem is, i successfully build the project and start debugger and i
> am able to execute the code step by step. It works as expected. But
> after closing the debugger and resetting the board( simply remove the
> usb cable and then reconnect it ) leds are always lit. My code is below
>
> #include "msp430x20x2.h"
>
> #define LED0 BIT0
> #define LED1 BIT6
> #define LED_DIR P1DIR
> #define LED_OUT P1OUT
>
> #define BUTTON BIT3
> #define BUTTON_OUT P1OUT
> #define BUTTON_DIR P1DIR
> #define BUTTON_IN P1IN
> #define BUTTON_IE P1IE
> #define BUTTON_IES P1IES
> #define BUTTON_IFG P1IFG
> #define BUTTON_REN P1REN
>
> #define TXD BIT1 // TXD on P1.1
> #define RXD BIT2 // RXD on P1.2
>
> #define APP_STANDBY_MODE 0
> #define APP_APPLICATION_MODE 1
>
> #define TIMER_PWM_MODE 0
> #define TIMER_UART_MODE 1
> #define TIMER_PWM_PERIOD 2000
> #define TIMER_PWM_OFFSET 20
>
> #define TEMP_SAME 0
> #define TEMP_HOT 1
> #define TEMP_COLD 2
>
> #define TEMP_THRESHOLD 5
>
> // Conditions for 9600/4$00 Baud SW UART, SMCLK = 1MHz
> #define Bitime_5 0x05*4 // ~ 0.5
> bit length + small adjustment
> #define Bitime 13*4//0x0D
>
> #define UART_UPDATE_INTERVAL 1000
> unsigned char BitCnt;
> unsigned char applicationMode = APP_STANDBY_MODE;
> unsigned char timerMode = TIMER_PWM_MODE;
>
> unsigned char tempMode;
> unsigned char calibrateUpdate = 0;
> unsigned char tempPolarity = TEMP_SAME;
> unsigned int TXByte;
>
> /* Using an 8-value moving average filter on sampled ADC values */
> long tempMeasured[8];
> unsigned char tempMeasuredPosition=0;
> long tempAverage;
>
> long tempCalibrated, tempDifference;
>
> void InitializeLeds(void);
> void InitializeButton(void);
> void InitializeClocks(void);
>
> void InitializeClocks(void)
> {
>
> BCSCTL1 = CALBC1_1MHZ; // Set range
> DCOCTL = CALDCO_1MHZ;
> BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO / 8 = 1MHz
> }
>
> void InitializeButton(void) // Configure Push Button
> {
> BUTTON_DIR &= ~BUTTON;
> BUTTON_OUT |= BUTTON;
> BUTTON_REN |= BUTTON;
> BUTTON_IES |= BUTTON;
> BUTTON_IFG &= ~BUTTON;
> BUTTON_IE |= BUTTON;
> }
> void InitializeLeds(void)
> {
> LED_DIR |= LED0 + LED1;
> LED_OUT &= ~(LED0 + LED1);
> }
>
> void Delay( int dcount )
> {
> int iz;
>
> for( iz = 0; iz < dcount; iz ++ ){}
> }
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
>
> InitializeClocks();
> InitializeLeds();
>
> while( 1 )
> {
> LED_OUT &= ~( LED0 + LED1 );
> Delay( 10000 );
> LED_OUT |= ( LED0 + LED1 );
> Delay( 10000 );
> }
>
> }
> Changing the delay count does not help. Changing build type from debug
> to release does not help. Probably i forget or miss something but i
> could not find out it.
>
> Any help is appreciated.
> Best regards,
>
> Firat
>
>