Jump to content
43oh

where i'm wrong? :(


Recommended Posts

i'm looking @ Litovsky Tutorial for MSP430 ( http://glitovsky.com/blog/?p=85 ), and exerces with Launchpad.. chapter 7, page 42... toggle led using switch.. i have this code:

 

1 #include "msp430x22x4.h"

2

3 void configureClocks();

4 volatile unsigned int i; // volatile to prevent optimization

5

6 void main(void)

7 {

8 WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

9 configureClocks();

10

11 // Configure LED on P1.0

12 P1DIR = BIT0; // P1.0 output

13 P1OUT &=

Link to post
Share on other sites

I think your condition is wrong. (P1IN & ~BIT3) does not do what you want. ~BIT3 is the bit-pattern with all bits 1 except bit 3 (0xFFFD), meaning that your test will never be dependent on the actual value of bit 3 in P1IN. If you instead use ((P1IN & BIT3) == 0) ,or simply !(P1IN & BIT3), the test will be true if bit 3 is 0.

 

Hope this help.

 

Cheers,

Paul

Link to post
Share on other sites
Aaahhhh, found it.

 

Assuming you're using CCS

 

According to page 31 of slau157, section B.5.2 Custom Boot Routine, you need to use __system_pre_init() instead of __low_level_init().

 

Whacky.

 

 

thank you man!

 

it's no very important, i can disable WDT in main too, i don't have a big init... but i will try ;)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...