Jump to content
43oh

HELP! What am I doing wrong????


Recommended Posts

I am trying to get an MSP430G32231 to work on a breadboard. Here is what I did:

 

I connected the MSP430G2231 to the breadboard. I connected VCC from the lanuchpad to the top right pin of the MSP430 on the breadboard. I then connected a wire from the top right pin of the mcu to the GND pin on the launchpad. However, the MCU does not respond.

 

What am I doing wrong???

 

Here's a picture of the setup:

setupr.png

 

And the code:

    //  use timer_a to generate one second ticks
   //  built with msg430-gcc, flash w/ mspdebug
   //

   #ifdef MSP430
   #include "signal.h"
   #endif
   #include 
   #include 

   volatile unsigned char second_passed=0;   // advance indicator
   volatile unsigned long ticks=0;   // 'clock' in seconds

   struct t{
     unsigned hour;
     unsigned minute1;
     unsigned minute2;
     unsigned seconds;
   }time;

   void main(void) {
     WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
     BCSCTL1 = CALBC1_1MHZ;      // Set DCO to 1MHz factory calibration value
     DCOCTL = CALDCO_1MHZ;
     P1DIR |= BIT0;
     P1DIR |= BIT1;// P1.0 output
     CCTL0 = CCIE;                             // CCR0 interrupt enabled
     CCR0 = 50000;
     TACTL = TASSEL_2 + MC_1;                  // SMCLK, upmode
     _BIS_SR(GIE);                 // enable interrupt

     //Initialize time to 12:00
     time.hour = 12;
     time.minute1 = 0;
     time.minute2 = 0;
     time.seconds = 0;

     while (1) 
     {
        if (second_passed) 
        {
         time.seconds += 1;       //Increase time by one second
 	  if(time.seconds == 60)   //Check if a minute has passed
         {  
    if(time.minute2 < 9)
           {
	time.minute2 += 1;
               //Send a pluse to minute2 MCU
    }
    else if(time.minute2 == 9 && time.minute1 <5)//Checks if 10 minutes have passed
           {
      time.minute2 = 0;
      time.minute1 += 1;
    }
    else if(time.minute1 == 5 && time.minute2 == 9)//Checks if an hour has passed
    {
      time.minute1 = 0; //Reset minutes back to zero
             //Send a pluse to Minute1 MCU
             time.minute2 = 0;
             //Send a pluse to Minute2 MCU
      if(time.hour == 12)//check if its 12:00
             {
	time.hour = 1; //Rest time back to 1:00
               //Send a pluse to hours MCU
      }
             else
             {
	time.hour += 1;//increase time by an hour
               //Send a pluse to hours MCU
      }
    }
         time.seconds = 0;//reset seconds to 0
         }//end of if seconds = 60
         second_passed = 0;
        }//end of if second_passed
     }//end of while
     //_BIS_SR(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
   }//end of main

   // Timer A0 interrupt service routine
   #ifdef MSP430
   interrupt(TIMERA0_VECTOR) Timer_A(void)

   #else
   #pragma vector=TIMERA0_VECTOR
   __interrupt void Timer_A (void)

   #endif
   {
     static unsigned int clicks=0;
     // we will get called at 1Mhz/50k = 20 times a seconds
     clicks++;
     if (clicks >= 20) {
        clicks = 0;
      ticks++;      // advance clock for each second
      second_passed = 1; // have a flag to tell back main loop
     }//if
     // the followng can be a HHMM colon seperator led
     // take them out if not needed
     if (clicks >= 10){
        P1OUT |= BIT0;
        P1OUT |= BIT1;// half second on
     }
     else
     {
        //P1OUT &= ~BIT0;               // half second off
        //P1OUT &= ~BIT1;
     }
     //P1OUT ^= 0x01;                  //  P1.0
   }

   /*
   for digits:

   while(input voltage at pinx >0){
     -increase digit, and depending on its position, determine whether it
      should be reset to 0 or off.
     -wait for input voltage at pinx to go back to zero
   }
   */
/*    
while (1) {
 if (PIIN &= BIT1) {    // detect a rising edge (hi)
  while (P1IN &= BIT1);   // wait for falling edge (low)
     // do your led display pin toggling here
 }//if
}//while
*/

Link to post
Share on other sites

For one, you only have power and ground going to the breadboard. You have no connection to RX or TX (P1.1/p1.2) or Led1 (P1.0) or RST or TEST. Basically, I'm assuming it is working, but either not programmed or just has nothing to do, in a empirical sense.

 

Either run wires to the breadboard for those pins, or if you are sure you have uploaded that code to the chip, add a resistor and led to pin 2 of the chip on the breadboard (anode to chip, cathode to ground)

 

Edit: looking at the code again, it will turn p1.0 and p1.1 on, and never off since you commented out the instructions for that. AND you defined your variable clicks INSIDE the interrupt, with a value of 0. EVERY time the interrupt is called, clicks will reset to 0. It will never reach 20 or 10, so it will never toggle the pins on in the first place.

Link to post
Share on other sites
I disabled everything in the code, all it's supposed to do is turn on P1.1 and P1.2, and I tested those pins with a volt meter and they are 0V. Do I still need to connect any other pins than VCC and GND for this to work?

 

Are you programming it on the breadboard? Then yes. You need to connect test and rst.

Link to post
Share on other sites
Edit: looking at the code again, it will turn p1.0 and p1.1 on, and never off since you commented out the instructions for that. AND you defined your variable clicks INSIDE the interrupt, with a value of 0. EVERY time the interrupt is called, clicks will reset to 0. It will never reach 20 or 10, so it will never toggle the pins on in the first place.

 

The code works fine with the MSP430 connected to the launchpad. When I take it off and connect it to the breadboard, nothing happens.

Link to post
Share on other sites

for breadboarding (w/o debugger connection and eventually w/o launchpad), u need to tie the RESET pin to Vcc (3.3v) otherwise your firmware won't start.

 

see this is my hookup, i am running the wires via the jumper block headers but it's the same.

 

http://www.simpleavr.com/msp430-projects/3p4w-clock/3p4w04.jpg

Link to post
Share on other sites
I disabled everything in the code, all it's supposed to do is turn on P1.1 and P1.2, and I tested those pins with a volt meter and they are 0V. Do I still need to connect any other pins than VCC and GND for this to work?

 

Are you programming it on the breadboard? Then yes. You need to connect test and rst.

 

I'm not programming it on the breadboard. I program it on the launchpad, then take it off the launchpad and put it on the breadboard. How do I run the MCU just off 3.5V source? Would test and rst be connected to ground?

Link to post
Share on other sites
for breadboarding (w/o debugger connection and eventually w/o launchpad), u need to tie the RESET pin to Vcc (3.3v) otherwise your firmware won't start.

 

see this is my hookup, i am running the wires via the jumper block headers but it's the same.

 

http://www.simpleavr.com/msp430-projects/3p4w-clock/3p4w04.jpg

 

I wish I could give you 100000 thanks for this! I just spent the last 4 hours trying to figure out why this wasn't working, and it was the reset pin! Thank you so much!!

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...