Jump to content

Search the Community

Showing results for tags 'servos'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 1 result

  1. I'm fairly new to specifically MSP430 development, so any help here is appreciated! I'm trying to send data to and from a Raspberry Pi connected over hardware UART. This I've tested and works. I'm also trying to run two servos on the MSP430 and the basic code I have for them has been tested and also works. The problem occurs when I try to put them together as my timer setup must clash somewhere. It seems to me that the serial communication is all set on TA0 while the other timer is set to TA1. I don't understand why this would prevent the UART from sending and receiving. Edit: I'm using the MSP430G2553 int main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer init_servos(); init_UART(); _BIS_SR(GIE); // Enable CPU interrupts while(1){ // Wait for incoming character _BIS_SR(LPM0_bits); // Enter low poser mode if (rxBuffer == 'a') { P1OUT |= BIT0; } } } void init_UART() { DCOCTL = 0x00; // Set DCOCLK to 1MHz BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; P1OUT = 0x00; // Initialize all GPIO P1SEL = UART_TXD + UART_RXD; // Timer function for TXD/RXD pins P1DIR = UART_TXD + BIT0; // TX and LED1 to Output // Configures Timer_A for full-duplex UART operation TA0CCTL0 = OUT; // Set TXD Idle as Mark = '1' TA0CCTL1 = SCS + CM1 + CAP + CCIE; // Sync, Neg Edge, Capture, Int TA0CTL = TASSEL_2 + MC_2; // SMCLK, start in continuous mode } void init_servos() { P2SEL |= BIT0 | BIT1; P2DIR |= BIT0 | BIT1; // Duty Cycle (585 - 675 - 765) TA1CCTL0 = OUTMOD_7; // reset/set (0) TA1CCTL1 = OUTMOD_7; // reset/set (1) TA1CTL = TASSEL_2 + MC_1; // SMCLK, up mode BCSCTL1 = 0x84; // CLK Info TA1CCR0 = 675; // Duty Cycle (2.0) TA1CCR1 = 675; // Duty Cycle (2.1) } void TimerA_UART_print(char *string) { // Prints a string using the Timer_A UART while (*string) TimerA_UART_tx(*string++); } void TimerA_UART_tx(unsigned char byte) { while (TACCTL0 & CCIE); // Ensure last char got TX'd TACCR0 = TAR; // Current state of TA counter TACCR0 += UART_TBIT; // One bit time till first bit TACCTL0 = OUTMOD0 + CCIE; // Set TXD on EQU0, Int txData = byte; // Load global variable txData |= 0x100; // Add mark stop bit to TXData txData <<= 1; // Add space start bit } #pragma vector = TIMER0_A0_VECTOR // Timer_A UART - Transmit Interrupt Handler __interrupt void Timer_A0_ISR(void) { static unsigned char txBitCnt = 10; TA0CCR0 += UART_TBIT; // Add Offset to CCRx if (txBitCnt == 0) { // All bits TXed? TA0CCTL0 &= ~CCIE; // All bits TXed, disable interrupt txBitCnt = 10; // Re-load bit counter } else { if (txData & 0x01) TA0CCTL0 &= ~OUTMOD2; // TX Mark '1' else TA0CCTL0 |= OUTMOD2; // TX Space '0' } txData >>= 1; // Shift right 1 bit txBitCnt--; } #pragma vector = TIMER0_A1_VECTOR // Timer_A UART - Receive Interrupt Handler __interrupt void Timer_A1_ISR(void) { static unsigned char rxBitCnt = 8; static unsigned char rxData = 0; switch (TA0IV) { // Use calculated branching case TA0IV_TACCR1: // TACCR1 CCIFG - UART RX TA0CCR1 += UART_TBIT; // Add Offset to CCRx if (TA0CCTL1 & CAP) { // Capture mode = start bit edge TA0CCTL1 &= ~CAP; // Switch capture to compare mode TA0CCR1 += UART_TBIT_DIV_2; // Point CCRx to middle of D0 } else { rxData >>= 1; if (TA0CCTL1 & SCCI) // Get bit waiting in receive latch rxData |= 0x80; rxBitCnt--; if (rxBitCnt == 0) { // All bits RXed? rxBuffer = rxData; // Store in global variable rxBitCnt = 8; // Re-load bit counter TA0CCTL1 |= CAP; // Switch compare to capture mode _BIC_SR_IRQ(LPM0_bits); // wake up from low power mode. } } break; } }
×
×
  • Create New...