Jump to content

Jake

Members
  • Content Count

    133
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Jake

  1. I am using CCS6 I am going to back to LAB 8 the UART lab to see if there is something mad with my launchpad or the terminal itself. What I dont get is the fact that I cant see any signals coming from the sensor at all. I figured I would see some data with the logic analyzer connected to it.
  2. Howdy everyone, Finally getting back to the microcontrollers. I have been trying to get the MSP and ADXL to work together. https://e2e.ti.com/support/microcontrollers/msp430/f/166/t/490264 I have been using this code and the ADXL from Adafruit they already has the pull up resistors on the board. From Adafruit example they are only using SDA and SCL and the 3v power. The red LED is only supposed to be on if the sensor is in certain positions. But it's on all the time. And I can not get anything to come up on the terminal screen even though it says connected. Has anybody else built one of these? Any where to start with the terminal connectivity or seeing if the sensor is functioning? I tried connecting SCL and SDA to my logic analyzer, both just show high but no signal. Thanks! Merry Christmas to yall! Sent from my XT1254 using Tapatalk
  3. Sprillis, It is TASSEL_2 Do I need a line to setup and start the BCS? Also on the DCOCTL I thought that was enough to tell it to go there, but I have not been able to get it to work, if you run it with the debugger, works perfectly. As soon as you are completely off of it back to no function. Desired pin goes high on start, but no response at all. I dunno I am stumped. // initialize Timer0_A TA0CCR0 = ( 10000 / TICKS_PER_SECOND ) - 1; // set up timer for 12.5Hz TA0CTL = TASSEL_2 + ID_3 + MC_1; // configure and start timer SFR_8BIT(BCSCTL2); SFR_8BIT(DCOCTL); // enable interrupts TA0CCTL0 = CCIE; // enable timer CCR0 interrupts __enable_interrupt(); // set GIE in SR LPM3; // select low power mode 3 while(1); } /** * Timer interrupt called at 32Hz (TICKS_PER_SECOND) */ #pragma vector = TIMER0_A0_VECTOR __interrupt void myTimerISR(void) { switch( current_state )
  4. Howdy Everybody, I am trying to figure out how to change this code from running on the crystal to running on the DCO. I already built the board this is going on and dumbed up and did not make any provisions for the crystal. I have not located the document that had the timer modes laid out to where I could understand the addressing of each of the timers. Thanks for the help! #include <msp430.h> #define LEDR BIT0 #define LEDG BIT6 #define BUTTON BIT3 const int TICKS_PER_SECOND = 32; enum {state_waiting, state_hold_high}; unsigned int current_state = state_waiting; unsigned int hold_timer = 0; void init(void) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; // Enable LED outputs and Button pullup P1OUT = BUTTON; P1DIR = LEDR + LEDG; P1REN = BUTTON; // Set up 32768Hz crystal BCSCTL3 |= XCAP_3; // select 12pF caps SHOULD DEL THIS LINE // initialize Timer0_A TA0CCR0 = ( 32768 / TICKS_PER_SECOND ) - 1; // set up timer for 32Hz //DC0CCRO = ( 125000 / TICKS_PER_SECOND ) -1; // REPLACE ABOVE LINE NEED TO ADU TA0CTL = TASSEL_1 + ID_0 + MC_1; // configure and start timer //BCSCTL2 |= SELM_0 + DIVM_8; // SETUP FOR TIMER TO REPLACE ABOVE DCO TIMER DIVIDE BY 8 // enable interrupts TA0CCTL0 = CCIE; // enable timer CCR0 interrupts CHANGE TO BCS? __enable_interrupt(); // set GIE in SR LPM3; // select low power mode 3 while(1); } /** * Timer interrupt called at 125Hz (TICKS_PER_SECOND) */ #pragma vector = TIMER0_A0_VECTOR __interrupt void myTimerISR(void) { switch( current_state ) { /* state waiting */ case state_waiting: if( ( P1IN & BUTTON ) == 0 ) { if( hold_timer >= TICKS_PER_SECOND * 2 ) { /* If button held for 2 seconds change state */ current_state = state_hold_high; hold_timer = 0; break; } else { /* If button pressed, but not for 2 seconds yet inc timer */ hold_timer++; } } else { /* Button not pressed, reset timer */ hold_timer = 0; } break; /* state hold high */ case state_hold_high: /* Set output high */ P1OUT |= LEDR; if( hold_timer >= TICKS_PER_SECOND * 60 ) { /* If timer has elapsed, set output LOW, switch state */ P1OUT &= ~LEDR; hold_timer = 0; current_state = state_waiting; break; } else { hold_timer++; } break; /* return to a idle state */ default: current_state = state_waiting; break; } } void main( void ) { init(); }
  5. I'll be working on it next week! Do y'all have any good sources on the i2c displays? Sent from my XT1254 using Tapatalk
  6. thanks for the link! I could use an Arduino also, I am going to try with the MSP first, that is a good idea with using two of them. The displays take up a bunch of pins, that was one reason I was thinking about using the UART and going back to the PC to save some pins. I am going to get rolling on it next week.
  7. I am going to try to pull this off! I have 5 weeks to get it done. This is for the elementary school that my kids go to, there all getting involved in getting the cars, track, and timing system all done. I was initially thinking a MSP430G2553 The controller would be able to Drop starting gate and start timing with a pushbutton ( I really want to do a drag race light tree, but I may be getting too ambitious) Record the time of each lane and write to display Lane lights to light up winner lane. I know I could build the lane win lights easily with components, but I am hoping to pull off the timing and display to screen. Something simple like print to cmdline screen or the UART interface in CCS. Sooo do yall think I am out of my mind trying to go with this approach or? I am thinking the lane sensors would just be photodiodes in the track, sending inputs back to the controller A Button input that will trigger the timer to start, and output to drop the start gate Capture the time of each lane upon a change in state of the input pin, stop timer on the input of the last pin. Thanks!
  8. Thanks! I will see if I can get the code written this week and get going on it. On the timers I thought the one timer would be dedicated to that process.
  9. I have another project where I have 4 analog signals that I need to convert to 4 digital signals. The update period on the hardware is about 1ms. I was thinking about using the 12bit A-D, since there is a A and B timer I thought I would be able to run two continuous signal sets through it. I would have to run two chips to get the job done. I am not crunched for space so if I have to run individual ones it is not the end of the world. This is for the torque meters from my analog servo drives to the LinuxCNC interface for my CNC mill control retrofit. Thanks guys!
  10. On the interrupts I have been told the same thing to keep them short, but instead of constantly polling I figured the interrupt would be better. Also this timing function is the most important function in the scheme of things, I want it to drop what ever else it was doing and go to this function. Everything else is able to wait while this evolution is taking place. Now I'll see if I can get my other pieces of the puzzle done!! Sent from my XT1254 using Tapatalk
  11. I CANT HIT THE THANKS BUTTON ENOUGH!!!!!! Thanks again Greg! It works great and makes sense, this has been a steep learning curve!
  12. I have been looking for some code snippets of the timer A up count mode Setting TA0CCR0 = 512 for 1 sec with the crystal hooked up and /8 Input low to start timer start timer in mode 6 toggle/set count ++ to get two seconds toggle output when condition reached output to start timer again in mode 7 reset/set (or use another timer if I have to) count CCRO 60 times for 60 seconds reset output Or I think I might be able to use output mode 2 toggle/reset, count 2 periods output high count 60 periods reset output I can not seem to find the code to set the timer modes to try this. I have dug through slap113 (timers in depth) and slau144j which helped me get to this line of thinking, but I can not find code snippets on the modes to get going on it. THANKS!!!
  13. I have finally had a bit more time to attempt this. I did find the real time clock documents, which someone else was using to capture a thermostat reading at specific intervals. I am not getting any errors in the code, but it will not build. I am not sure where I have gone wrong. Do yall see anything that I could do to get this rolling ? #include "RTC.h" #include "msp430g2553.h" void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR |= 0x01; // Set P1.0 to output direction CCR0 = 32768 - 1; TACTL = TASSEL_1 + MC_1; // ACLK, upmode CCTL0 |= CCIE; // enable CCRO interrupt _EINT(); P1OUT &= 0x00; // Shut down everything P1DIR &= 0x00; P1DIR |= BIT0 + BIT6; // P1.0 and P1.6 pins output the rest are input P1REN |= BIT3; // Enable internal pull-up/down resistors P1OUT |= BIT3; //Select pull-up mode for P1.3 P1IE |= BIT3; // P1.3 interrupt enabled P1IES |= BIT3; // P1.3 Hi/lo edge P1IFG &= ~BIT3; // P1.3 IFG cleared while (1) { LPM3; // enter LPM3, clock will be updated P1OUT ^= 0x01; // do any other needed items in loop _NOP(); // set breakpoint here to see 1 second int. } } // Timer A0 interrupt service routine #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A(void) { incrementSeconds(); LPM3_EXIT; } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { if(P1IN & BUTTON); // Start timer when button is high incrementSeconds(2); // count 2 seconds as long as button is high P1OUT |= BIT6; // Set output high incrementSeconds(60); // count 60 seconds after output is high P1IFG &= ~BIT6; // Clear IFG, reset P1.6 low }
  14. Awesome THANKS!! I will see if I can get it to work with that. What I am trying to do is if there is an continuous input for at least 2 seconds for it to make an output high, after the output goes high reset the output to low after 60 seconds. I am trying to use one remote button to do multiple tasks, a short push will allow one action to happen, a long (2 sec) push will allow a different action to occur. If (BUTTON HIGH) //check for input pin high START TIMER COUNT 2 SECONDS //start and run timer as long as input is high MAKE OUTPUT PIN HIGH // if it makes it to the 2 seconds make output pin high START TIMER COUNT 60 SECONDS // count down timer RESET OUTPUT TO LOW // reset output pin to low after 60 seconds elapses
  15. I am still trying to get through this no luck so far void delay_for_1_second() { // Add some code here to delay for 1 second <-----I am not sure what I need to add here } void check_input() { if (P1IN & BIT3) \\input high \\see if it stays there for 2 seconds for( int i = 0 ; i < 2 ; i++) { delay_for_1_second(); if(!(P1IN & BIT3)) // if pin low, do not turn output on return; } P1OUT |= BIT6; \\ make output high for( int i = 0 ; i < 60 ; i++) { delay_for_1_second(); } P1OUT &= ~BIT6 \\reset P1OUT to low } Would this work for the interrupt like the button high will trigger the interrupt Then the timer starts making sure the button is high for the duration of the timer (2 seconds) Makes the output high Triggers timer again counts 60 seconds then resets the output back to low. It also says "i" is undefined, I need to add that to the #define i (......dont know what) in the define sections Thanks again!!
  16. ok so I need to setup this timer arraignment in the timer AO ISR right? I found the TI timers in depth PDF it seems like I need to have the timer in compare mode to cause an event after a certain period of time. So those time instructions need to be in the timer ISR ? Ill keep working the googlefu to get this figured out. or is there supposed to be a line in the timer ISR to run the timer, Then in the port ISR you have instructions to wait for x time, then set the pin high, then wait set time again and reset? Thanks again for the help!
  17. #include "msp430g2553.h" #define system_tick #define button BIT3 //P1.3 #define ledr BIT0 //P1.0 #define ledg BIT6 //P1.6 void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT TA0CCTL0 = CCIE; // CCR0 interrupt enabled TA0CTL = TASSEL_2 + MC_1 + ID_3; // SMCLK/8, upmode TA0CCR0 = 50000; // Hz P1OUT &= 0x00; // Shut down everything P1DIR &= 0x00; P1DIR |= BIT0 + BIT6; // P1.0 and P1.6 pins output the rest are input P1REN |= BIT3; // Enable internal pull-up/down resistors P1OUT |= BIT3; //Select pull-up mode for P1.3 P1IE |= BIT3; // P1.3 interrupt enabled P1IES |= BIT3; // P1.3 Hi/lo edge P1IFG &= ~BIT3; // P1.3 IFG cleared _BIS_SR(CPUOFF + GIE); // Enter LPM0 w/ interrupt while (1) //Loop forever, we work with interrupts! { } } // Timer A0 interrupt service routine #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A(void) { } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { TA0CCR0 += 500000; // Delay interupt must have P1.3 high for 2 sec P1OUT |= ledg; // Set P1.6 high TA0CCR0 += 500000; // Reset interrupt after 60 seconds P1IFG &= ~button; // P1.3 IFG cleared P1OUT &= ~ledg; } Well I have kinda gotten closer. I will try some the approach Greeeg stated as I saw this after I got to this point. With the above code I can see the LED barely flicker on and back off. With the timing so fast at the moment that is all it gets. I need to make the times longer. If I add to the cycles it just says truncated numbers and sets it back to what it wants. I wish I could find someone local to get some lessons from.
  18. I'm using CCS also... Sent from my XT1254 using Tapatalk
  19. I'll try that. I have close to that in my code at the moment but the input still goes high instantly, as soon as the button is pressed. Sent from my XT1254 using Tapatalk
  20. I am trying to put a piece of my program in with a time delay. If I get input high for like a full second then the output will go high. I tried with a long switch debounce, but the output still went high right after the input was there. { if (P1IN & BIT3) \\input high then (delay 2 seconds) \\see if it stays there for 2 seconds P1OUT |= BIT6; \\ make output high then (delay 60 second) \\output high for 60 seconds P1OUT &= ~BIT6 \\reset P1OUT to low } Thanks everybody!
  21. #include "msp430g2553.h" void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT CCTL0 = CCIE; // CCR0 interrupt enabled TACTL = TASSEL_2 + MC_1 + ID_3; // SMCLK/8, upmode CCR0 = 10000; // 12.5 Hz P1OUT &= 0x00; // Shut down everything P1DIR &= 0x00; P1DIR |= BIT0 + BIT6; // P1.0 and P1.6 pins output the rest are input P1REN |= BIT3; // Enable internal pull-up/down resistors P1OUT |= BIT3; //Select pull-up mode for P1.3 P1IE |= BIT3; // P1.3 interrupt enabled P1IES |= BIT3; // P1.3 Hi/lo edge P1IFG &= ~BIT3; // P1.3 IFG cleared _BIS_SR(CPUOFF + GIE); // Enter LPM0 w/ interrupt while(1) //Loop forever, we work with interrupts! {} } // Timer A0 interrupt service routine #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A (void) {} // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void PORT1_ISR(void) { P1OUT ^= BIT6; // Toggle P1.6 P1IFG &= ~BIT3; // P1.3 IFG cleared } ok I got it to work where I can toggle the output on and off from the input. Now I just need to debounce the switch where the input signal is there for greater than two seconds and have the interrupt reset after 60 seconds. ! Changing the bitwise to make it high I think will work better also. I do not want it to toggle back and forth, just go high, reset after time. Thanks for the help!
  22. Ok I'll try that tonight, it loads but the state of the output pin never changes. Just stays low. Sent from my XT1254 using Tapatalk
  23. I have been trying to figure this one out. I want to run an interrupt upon a trigger from an input, in the interrupt it will cause a pin to go high. I want to make this function as the interrupt will be reset by another input or by a set time. This is the code that I have found and attempted to change to work with the MSP430G2553, but I can not get it to work. What do I need to do to get this to work ? Thanks!!!! #include "msp430g2553.h" void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT TA0CCTL0=CCIE; // CCR0 interrupt enabled TA0CTL = TASSEL_2+MC_1+ID_3; // SMCLK/8, upmode TA0CCR0=10000; // 12.5 Hz P1OUT &= 0x00; // Shut down everything P1DIR &= 0x00; P1DIR |= BIT0 + BIT6; // P1.0 and P1.6 pins output the rest are input P1REN |= BIT3; // Enable internal pull-up/down resistors P1OUT |= BIT3; //Select pull-up mode for P1.3 P1IE |= BIT3; // P1.3 interrupt enabled P1IES &= ~BIT3; // P1.3 Hi/lo edge P1IFG &= ~BIT3; // P1.3 IFG cleared _BIS_SR(CPUOFF + GIE); // Enter LPM0 w/ interrupt while(1) //Loop forever, we work with interrupts! {} } // Timer A0 interrupt service routine #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A (void) { P1OUT ^= BIT0; // Toggle P1.0 } // Port 1 interrupt service routine #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { P1OUT ^= BIT6; // Toggle P1.6 P1IFG &= ~BIT3; // P1.3 IFG cleared }
  24. It will be nice as the other driver can only handle 240 watts. I have a project I'm working on with it. Writing the code is still kicking my butt though!
×
×
  • Create New...