Jump to content


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Like
    Sillycrackers reacted to oPossum in MSP430G2553 PWM Outputs   
    3 on 20 pin package or 4 on 28 pin package (SMD only)
    There are 8 analog inputs on P1.0 to P1.7 and only one PWM output conflicts with that range, so you could have 7 analog in, but will also loose hardware UART/SPI/IIC because those share pins with the ADC.
    Timer A0 CCR0: P1.1 or P1.5
    Timer A0 CCR1: P1.2 or P1.6
    Timer A0 CCR2: P3.0
    Timer A1 CCR0: P2.0, P2.3, P3.1 or P3.4
    Timer A1 CCR1: P2.1, P2.2, P3.2 or P3.5
    Timer A1 CCR2: P2.4, P2.5, P3.3 or P3.6
    CCR0 can not be used for PWM. Port 3 in only on 28 pin package.
    For some applications, you may be able to use software PWM. That works on any pin.
  2. Like
    Sillycrackers reacted to RobG in ADC10 multiple inputs   
    Sorry about that. Added your P2 code and updated my original post, try now, P2.2 is controlled by A0 (P1.0)
    Also, values in the array are reversed, A0 is in [5], A5 in [0], and remember to remove jumpers (LED0, RXD, and TXD,) they may affect ADC readings.
  3. Like
    Sillycrackers reacted to RobG in ADC10 multiple inputs   
    Try this

    #include unsigned int adcValues[6] = { 0, 0, 0, 0, 0, 0 }; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; P2DIR |= BIT2; P2OUT &= ~BIT2; ADC10CTL1 = INCH_5 + CONSEQ_1; ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; ADC10DTC1 = 0x06; ADC10AE0 |= 0x3F; 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_A0_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) { //ADC is done, do something with adcValues if (adcValues[0] > 500) { // A5 is in adcValues[0], A0 in adcValues[5] P2OUT |= BIT2; } else { P2OUT &= ~BIT2; } }
  4. Like
    Sillycrackers reacted to oPossum in ADC10 multiple inputs   
    Poll the interrupt flag, not the busy flag. It will always appear busy when doing continuous conversion.

    ADC10CTL0 &= ~ADC10IFG; // Clear ADC conversion conplete flag while(!(ADC10CTL0 & ADC10IFG)); // Wait for flag to be set
  5. Like
    Sillycrackers reacted to oPossum in MSP430G2553 Launchpad   
    PxDIR sets the port pin direction - 0 = input, 1 = output
    PxOUT will set the output level of the pin if it is configured for output. If the pin is configured for input and the pull up/down resistor is enabled (with PxREN), then PxOUT will determine if pull up or pull down is used. 0 = pull down, 1 = pull up
    So by setting bit 3 of P1OUT the pull up resistor for that pin was enabled instead of the pull down resistor. This is necessary because the switch on P1.3 connects it to ground, so you want it pulled high.
  6. Like
    Sillycrackers reacted to RobG in MSP430G2553 Launchpad   
    Add P1OUT |= BIT3;
  7. Like
    Sillycrackers reacted to Rickta59 in io430.h file   
    #include // pulls in processor specific headers
    CCS doesn't provide structure access as described in the book.
  • Create New...