Jump to content
43oh

omerdf

Members
  • Content Count

    20
  • Joined

  • Last visited

Reputation Activity

  1. Like
    omerdf reacted to zeke in Problem in programming a MSP430 MicroController   
    @omerdf, I just dealt with the same problem last night.
    I had two competing pull up resistors on the Reset/Test line between my CPU board and my Support board.
    The strong 1K pullup on the manual reset circuit was interfering with the programming port. 
    I had to temporarily remove the R4 and C1 of the Manual Reset Control circuit and then the board would program.
    Does this help?
     


     
     
  2. Like
    omerdf reacted to NurseBob in "Fatal Error:Could not find device " Error in MSP-FET and MSP430   
    If I am misunderstanding, I apologize in advance...
    >In the msp430 family datasheet they mention a unused pins , they say that if AVcc and AVss are not in use they should be connected to DVcc and DVss  - i think they get their supply from the digital pins.
    Are you saying there's no physical external connection between AVcc and DVcc? That seems to be what your schematic implies.  If that's the case, aside from whatever else may be happening, there's no power to the side.
    Per this post, you may be seeing a related problem.
  3. Like
    omerdf reacted to chicken in Generate 1 pulse per second using MSP430   
    Simply wire up J1 to the respective pins on the programmer. See the last column of table 6 in the MSPFET documentation.
    http://www.ti.com/lit/ug/slau647f/slau647f.pdf
  4. Like
    omerdf reacted to chicken in Generate 1 pulse per second using MSP430   
    The error is not related to the code that you posted.
     
    Make sure to only include msp430.h.
  5. Like
    omerdf reacted to chicken in Generate 1 pulse per second using MSP430   
    You only need to clear P2IFG if you use interrupts triggered by voltage changes on a given pin. You are using a timer interrupt and wiggle the output "manually", which is unrelated.
     
    I'm also getting confused on your requirements. If one 1PPS signal with a certain duty cycle (e.g. 250ms high, 750 ms high) is all you need, I would simply count to 1000 and then use that variable in the main loop.
     
    i.e.
    if (input pins indicate I should drive the clock signal ) {   set pin as output   if (timer_counter < 250) { set pin high }   else { pin low } } else {   set pin as input to not disturb other sources of the clock signal } I don't think this "remote programming" is very fruitful unless you actually do it on the real system and use an oscilloscope or logic analyzer to verify whether the system does what you expect.
  6. Like
    omerdf reacted to chicken in Generate 1 pulse per second using MSP430   
    Ooops, wrong thinking :-)
     
    You want every 2 seconds. So it's
    ISR {   timerCount++;   if(timerCount == 1000) {     timerCount = 0;     secondsCount++;     // set your once a second flags   }   if(secondsCount == 2) {     secondsCount = 0;     // set your every 2 seconds flags   } }
  7. Like
    omerdf reacted to chicken in Generate 1 pulse per second using MSP430   
    So, does it work wiggling P2.4?
     
    You can read and react to inputs within the interrupt, so there's not an absolute need to communicate with the main thread. E.g, within the ISR:
    if(++timerCount > 1000) { timerCount = 0; if(pin indicates mode 1) { do 1 } else if (pin indicates mode 2) { do 2 } } An alternative approach is to use the ISR just to keep track of time, and move everything else into the main loop. You may add another flag to indicate that a second passed. e.g. in the ISR:
    if (++timerCount > 1000) {   timerCount = 0;   secondFlag = 1; } Then in the main loop:
    forever {   if(secondFlag == 1) { // wait for flag to be set   secondFlag = 0; // do whatever you need to do once a second } } You could maintain other flags if you need to support more time periods. Make sure to use the volatile keyword when declaring variables that you want to pass between the ISR and main loop.
     
    An even more refined program structure would set a mode variable depending on inputs, then have a switch statement covering the different modes.
    forever { if(secondFlag == 1) { secondFlag = 0;   mode = depending on input pins;   switch(mode) {      case 1:        do what we need to do for mode 1;       break;      case 2:       do what we need to do for mode 2;      break;     default:      do nothing;    } } } And just like that, you wrote your first state machine. You may move the secondFlag check into the case statements if the modes don't share the timing requirements.
     
    PS: You clear the pin 2 interrupt flag (P2IFG) in your ISR. This register is not related to timer interrupts. So no need to clear it.
     
    PS2: Busy-waiting in the main loop is not very efficient in regards to power consumption, but we will leave optimizing that to the very end when everything else works.
  8. Like
    omerdf reacted to chicken in Generate 1 pulse per second using MSP430   
    You could do that. But with your simple task, it is probably easier to use an interrupt.
     
    The most common approach for simple pin wiggling based on the timer is to setup a timer interrupt that fires every millisecond and maintaining a millisecond counter.
     
    Main:
     
    - set a millisecond counter variable to 0
    - setup timer to up mode, divide clock by 8, etc. (TA0CTL)
    - set compare register to 1600, so that the timer interrupt occurs 1000 times per second (12.8M / 8 / 1600 = 1000) (TA0CCR0)
    - enable timer interrupt
    - go into endless loop
     
    Inside the interrupt:
     
    - increase millisecond counter variable
    - if it reaches 1000, 1 second passed
    -- reset your millisecond counter to 0
    -- do your thing depending on state of input pin
     
    See MSP430 family guide chapter 17.2 through 17.2.3.1.1
    http://www.ti.com/lit/ug/slau208p/slau208p.pdf
     
    Here's a very similar example. Note that the timer registers may have slightly different names as it's for a different MCU.
    http://www.crash-bang.com/getting-started-msp430-timers-3/
     
    PS: You only need to include msp430.h. Together with the MCU selection in the CCS project, it will take care to include the correct files.
  9. Like
    omerdf reacted to chicken in Generate 1 pulse per second using MSP430   
    PS: You may want to start with a basic tutorial on timer interrupts. E.g.
    https://www.embeddedrelated.com/showarticle/182.php
  10. Like
    omerdf reacted to chicken in Generate 1 pulse per second using MSP430   
    Welcome to the forum.
     
    RST and TEST are the connections to program and debug your MCU. If you haven't already, get a MSP430FET or a newer MSP430 LaunchPad (e.g. MSP430F5529LP). This is required to load your application into the MCU. Also see http://43oh.com/2011/11/tutorial-to-use-your-launchpad-as-a-programmer/
     
    There can only be one interrupt service routine (ISR) for a given interrupt vector (e.g. TIMER0_D0_VECTOR in your code). And I don't think you can declare an ISR within another function. Move the ISR to the end of your code, outside of main. If the ISR needs to do different things depending on certain conditions, you need to handle that within one ISR using some state flags.
     
    It also looks like the configuration of Timer D0 is only halfway done. You will have to look at the datasheet and family user's guide to learn more about how to configure the peripherals of your MCU. The product page on ti.com is a good start to find relevant documentation:
    http://www.ti.com/product/MSP430F5131
×
×
  • Create New...