Jump to content

athornsb

Members
  • Content Count

    20
  • Joined

  • Last visited

About athornsb

  • Rank
    Member

Profile Information

  • Location
    NCSU
  1. Ok so I'm actually using RobGs code now plugged into my interrupt. P2IES=0, and the pullup resistors are turned on. Turning the switch either direction it only counts down, and seems to fire multiple times per transition. (I'm about to try debouncing this)
  2. It is configured for 0 to 1 detection (P2IES=0x00). It seems like maybe the processor isn't referencing ground/0 correctly.
  3. Hey all, I'm completely stumped on a bug for my design day project. I've got a rotary encoder that is used to change a value on an LCD screen. The code works perfectly when the encoders state at power up is 00. However if either pin is high, it doesn't work at all. Some transitions will cause the value on the screen to move in the wrong direct, and some transitions don't seem to trigger an interrupt at all. This is the code I'm using and would LOVE some help! Is it possible that the MSP430 is recording the initial values as reference voltages causing subsequent interrupts to not work? #pragma vector=PORT2_VECTOR //Port 2 interrupt triggered by either rotary encoder pin __interrupt void Port_2(void) { //int gray0=P2IN&GRAY0; //int gray1=P2IN&GRAY1; if(P2IFG&GRAY0) { (P2IN&GRAY1)? parameter++ : parameter-- ; if(parameter>999) parameter=0; P2IFG&=~GRAY0; } else if(P2IFG&GRAY1) { (P2IN&GRAY0)? parameter++ : parameter-- ; P2IFG&=~GRAY1; if(parameter<0) parameter=999; } inactivity=0; //interaction has been seen, so reset the inactivity counter }
  4. Thanks to both of you. I used something similar to what you both mentioned. Since I need LPM3 for my application, I used the basic principles you two mentioned except with my VLO sourced timer A0. I essentially wrote my existing encoder interrupt into the timer with a way to measure delay. Now all I do in my encoder interrupt is: inactivity=0; //reset the inactivity counter sample_flag=1; P2IE &= ~GRAY0; //deactivate further switch interrupts P2IE &= ~GRAY1; Once the delay has been measured with the timer and a sample taken, it clears the P2IFG flags and reactivates the two interrupts. This prevents the encoder interrupt from firing many times, and hopefully introduces enough delay to get a good reading from the two pins. I haven't tested it with our hardware yet, but I expect this may work.
  5. Rob, my only worry is if 32ms may be too long for a rotary encoder. That would give me a maximum of 30 position changes/second which seems reasonable, I just don't want to end up missing more than 1-2 position changes since that could confuse the software about which direction its spinning. Since your option is the easiest in terms of how much extra code I have to write I think I'll try that first.
  6. Hey road runner, could you explain how that main code functions? I need my code to stay in low power mode 3 as much of the time as possible (it's a low-power solar application). It would be ideal to have a debounce flag, controlled by my timer ISR, that could wake the CPU temporarily to sample the value of the gray code switch. Ike thanks, but I don't think that debounce code will work for my application. That code appears to check the switch only so often to avoid the stutter you typically get with a bunch button. However with a rotary gray code switch, I need more of an average. At the moment when you turn the switch, some of the extra oscillations trigger subsequent interrupts and you cant smoothly/reliably change the value on the screen. What I hope to do is the first time the switch triggers the interrupt, set in motion a series of 1ms separated samples. After n number of samples i just want to see whether more 0s or 1s were seen on each of the two pins.
  7. Hey all. I'm using an msp430g2553 to output an integer to an LCD and let that integer to be modified with a rotating gray code switch. I am attempting to debounce the switch by sampling its value every 1ms for 5ms (5 samples) each time the switch interrupt fires. I am trying to accomplish this with the following code: for(i=0; i<SAMPLE_NUM; i++) { ms=0; while(ms==0) { //do nothing until at least 1 ms has elapsed } gray0_val = P2IN&GRAY0; //latch current port pin values gray1_val = P2IN&GRAY1; The issue is at line 2-3 where I reset a 1ms global variable counter. This gets incremented by my timer 0 A0 interrupt at a rate of 12000Hz. (yes I know thats not exactly 1 ms, but it doesnt matter) After I reset the variable, the idea is to wait until the timer interrupt increments it again and then sample the gray code switch value. However, instead my code is getting stuck here, and it's preventing the timer interrupt from ever firing. I looked up ISR priorities in the user guide, and it appears that the timer interrupt priority is higher than port 2. That means that in theory this SHOULD work, but something is going wrong. If you guys could help me solve it that would be great!! P.S. I know its not usually good practice to interrupt an interrupt, but we are close to a deadline and this is the easiest way we've come up with to debounce effectively.
  8. Actually I see now that it's the P1SEL definition that controls if the pin is pulse width modulated, allowing me to use that option to send it to just one of my pins. Sorry, please ignore this post!
  9. I'm looking to refresh the LCD in our project at 30-90Hz. I have found the included code online, but don't understand how the signal is being tied to the output pins. I have a lot of pins set to output already, and need the PWM signal to only be present on one. Oh, and because of intense power restrictions, I am using the VLO for my timer interrupts and will need to use it for the PWM signal as well. NOTE: the PWM mode that toggles from high to -high will need to be used, instead of high to ground. Thanks guys! #include "msp430x21x2.h" void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR |= 0x0C; // P1.2 and P1.3 output P1SEL |= 0x0C; // P1.2 and P1.3 TA1/2 otions TA0CCR0 = 512 - 1; // PWM Period TA0CCTL1 = OUTMOD_7; // TA0CCR1 reset/set TA0CCR1 = 384; // TA0CCR1 PWM duty cycle TA0CCTL2 = OUTMOD_7; // TA0CCR2 reset/set TA0CCR2 = 128; // TA0CCR2 PWM duty cycle TA0CTL = TASSEL_2 + MC_1; // SMCLK, up mode __bis_SR_register(CPUOFF); // Enter LPM0 }
  10. That's perfect, thanks. I'm gonna head off and watch the low power video for anything I missed, and then go back to the lab and re test this thing! Oh and it may have been, I can't remember (I assumed this was some TI chip i wasn't familiar with). I used it in a class for NC State, but that class is actually moving away from Renesas in favor of TI now.
  11. Actually it's a senior project. We are using a G series launchpad for now, but will be transitioning to a 1 series chip on a bread board once all of the code works.
  12. Oh just to give you a little more info about the project..... It's incredibly simple. We need an MSP430 connected to a solar cell or cells, a 3 digit LCD, and a graycode switch. The MCU will let users change a single parameter with the switch, and output the value to the display. It also must run off a relatively small solar cell, and spend much of its time in a low light space. We are designing a little additional hardware to power it (cap(s) and maybe a charge pump, so instantaneous power draw isnt much of a concern). I don't anticipate needing more than 2 counter interrupts and a single switch interrupt, so we really just want the thing asleep in LPM3 as much as possible.
  13. Ok so that means I dont need to set ADC10 Data Transfer Control or ADC10 Control bits? Again thanks, I've programmed a Renesas micro controller before, but never a TI, so a lot of this is new to me.
  14. Thanks, I'll check out those getting started labs just to be sure. Ok last 2 questions, hopefully!... What is the most power efficient way to debounce a switch? In the past I just incremented a global variable with a fast timer interrupt, but I would hate to wake our system that often. Do I need to turn the ADC off in some way, or has switching off any unnecessary clocks already accomplished this? I read elsewhere that the ADC is a power hog and can interfere with LPM. Thanks.
  15. Oh is there anything I need to know about testing the power draw? If your suggestions don't reduce the power dramatically, I'll be totally at a loss. We have been connecting the Vcc and ground to a 2.2V power supply (after removing the MSP430 from the launchpad board). Then we connect a multimeter to measure the current draw.
×
×
  • Create New...