Jump to content

Sillycrackers

Members
  • Content Count

    12
  • Joined

  • Last visited

About Sillycrackers

  • Rank
    Member

Profile Information

  • Sparkfun
    Stepper drivers
  1. Sillycrackers

    ADC Interrupt not working

    Hi, I am having trouble getting the ADC interrupt working for the msp430g2452. I am simply trying to turn on a flag when the interrupt goes off but it doesn't seem to be working. Code below.... #include <msp430g2452.h> void initAdc(); volatile char flag = 0; int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1DIR |= BIT6; P1OUT &= ~BIT6; initAdc(); __bis_SR_register(GIE); while(1){ if(flag == 1){ P1OUT |= BIT6; }else{ P1OUT &= ~BIT6; } } return 0; } void initAdc(){ ADC10CTL1 = CONSEQ_2 + ADC10DIV_3; //Channel A0 for conversion, ADC10OSC clock used for sampling, repeat single channel ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE + ADC10SC + ENC; //sample and hold time every 16 clocks, Multiple sample conversion, turn on ADC, enable interrupts for ADC, every 16 clock cycles take a sample ADC10DTC1 |= 0x01; //Number of transers in each block ADC10AE0 |= 0x01; //Enables the corresponding pins for analog inputs } #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { flag = 1; }
  2. Sillycrackers

    MSP430G2553 PWM Outputs

    Okay, So lets say i only need 2 pwm outputs for 2 motors and I have 6 sensors that need to hook up to the adc inputs. What pins would you recommend I hook these up to? (I have the 20 pin package) Thank you
  3. Sillycrackers

    MSP430G2553 PWM Outputs

    Hello quick question here, How many Pwm outputs does the G2553 chip have? I am trying to read the datasheet: http://www.ti.com/lit/ds/symlink/msp430g2553.pdf but it is hard to get a straight answer. I need 4 individual Pwm outputs and 6 ADC inputs is this possible without interfering with each others pins? Thank you.
  4. Sillycrackers

    ADC10 multiple inputs

    It Works! Thanks Bro.
  5. Sillycrackers

    ADC10 multiple inputs

    I tried the code RobG but since I'm using a different chip then you I think I have to change the timer vector name but I'm not sure what to so I tried : #pragma vector = TIMER0_A1_VECTOR And I also added: P2DIR |= BIT2; P2OUT &= ~BIT2; and: #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { if (adcValues[1] > 500){ P2OUT |= BIT2; } } Full Code: #include "msp430g2553.h" #include unsigned char valueIndex = 0; unsigned int adcValues[6] = {0,0,0,0,0,0}; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; ADC10CTL1 = INCH_5 + CONSEQ_1; ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; ADC10DTC1 = 0x06; ADC10AE0 |= 0x3F; P2DIR |= BIT2; P2OUT &= ~BIT2; CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 180; // sample every ~1.5ms TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK/8, upmode _bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt } // Timer A0 interrupt service routine #pragma vector = TIMER0_A1_VECTOR __interrupt void Timer_A (void) { ADC10CTL0 &= ~ENC; // disable conversion while (ADC10CTL1 & BUSY); // make sure ADC is done ADC10SA = (unsigned int)&adcValues[0]; // set data buffer start address ADC10CTL0 |= ENC + ADC10SC; // start sampling and conversion } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { if (adcValues[1] > 500){ P2OUT |= BIT2; } } But it is not working still.
  6. Sillycrackers

    ADC10 multiple inputs

    Okay Thank you. Would you also happen to know how I would be able to tell which individual input went over my setpoint?
  7. Sillycrackers

    ADC10 multiple inputs

    Hello, I am currently working on a linefollowing robot car. I plan on having 6 analog sensors that will be hooked up to P1.0 - p1.5. 'm new to this style of programming I'm trying to make the adjustment from arduino! Anyways right now I'm just debugging and trying to light an led when the either of the inputs go over a certain value. For some reason it is not working. Also when it comes time to make the line follower I will need to know what specific input is going over the setpoint is there a way to know which individual input went over ? Thank you. #include "msp430g2553.h" #include float volts = 0; void ADC_init(void); void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer ADC_init(); P2DIR |= BIT2; P2OUT &= ~BIT2; for(; { ADC10CTL0 |= ADC10SC; // start a new conversion while ((ADC10CTL1 & ADC10BUSY) == 0x01); // wait for conversion to end volts = ADC10MEM; if(volts>500){ P2OUT |= BIT2; } } } void ADC_init(void) { // Use Vcc/Vss for Up/Low Refs, 16 x ADC10CLKs, turn on ADC ADC10CTL0 = SREF_0 + ADC10SHT_2 + ADC10ON; // A1 input, use ADC10CLK div 1, single channel mode ADC10CTL1 = INCH_5 + SHS_0 + ADC10SSEL_0 + ADC10DIV_0 + CONSEQ_1; ADC10AE0 = BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5; // Enable ADC inputs ADC10CTL0 |= ENC; // Enable conversions. }
  8. Sillycrackers

    io430.h file

    Hello, I am new to the msp430. I have a launchpad and am using the msp430g2553. I am learning from the text "MSP430 Microcontroller Basics" but in the book the author uses the header file io430.h. I tried to include that in one of my projects but it seems I do not have it available in my compiler ( I am using CCS). Would anyone happen to know where I would aquire this header file so I can use it in CCS? Thank you.
  9. Sillycrackers

    MSP430G2553 Launchpad

    Thanks a lot this was driving me nuts Great explanation.
  10. Sillycrackers

    MSP430G2553 Launchpad

    Okay I understand Binary math but I thought that the ports were automatically set as inputs?
  11. Sillycrackers

    MSP430G2553 Launchpad

    Oh man Thank you so much. Would you mind explaining what this actually does?
  12. Sillycrackers

    MSP430G2553 Launchpad

    Hello, I am having trouble setting up the on board push button to port P1.3. For some weird reason when I hold my fingers on the male headers for the MCU pins the button works otherwise it doesn't work. I understand that you need to activate the internal Pull up resister which I have tried but yet I still cannot achieve any sort of progress with properly using the push button. Here is my code Thanks in advance. #include "msp430g2553.h" // Pins for LED and button on port 2 #define LED1 BIT0 #define B1 BIT3 void main (void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1OUT = LED1; P1DIR = LED1; // LED1 pin output , others input P1REN |= B1; for (; { // Loop forever while ((P1IN & B1) == 0) { // Loop while button up } // Actions to be taken when button is pressed P1OUT &= ~LED1; while ((P1IN & B1) != 0) { // Loop while button down } // (active low) doing nothing // Actions to be taken when button is released P1OUT |= LED1; } }
×