This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

1 minute interrupt based timer

Hi,

 

I want to have 1 min interrupt based counter for my project.

I tries timersA/B but they don't go to 1 min.I tried RTC also but it is creating some problem in my code.And my controller is getting in to infinite loop.

 

//  RTCCTL01 = RTCBCD+RTCHOLD+RTCMODE+RTCTEVIE+RTCAIE;

//                                        // RTC Mode, BCD mode,

//                                        // alarm every Minute,

//                                        // enable RTC interrupt

//  // Init time

//  RTCSEC =  0x00;                       // Set Seconds

//  RTCMIN =  0x00;                       // Set Minutes

//  RTCHOUR = 0x08;                       // Set Hours

//

//  // Init date

//  RTCDOW =  0x02;                       // Set DOW

//  RTCDAY =  0x23;                       // Set Day

//  RTCMON =  0x08;                       // Set Month

//  RTCYEAR = 0x2010;                     // Set Year

//

//  RTCCTL01 &= ~RTCHOLD;                 // Enable RTC

 

is the simple code.Can anybody please suggest me how can i do that?

 

Regards.

  • If you cannot have 1 min interrupt but do have 1 sec interrupt, you can count 60 sec as 1 min.

    It is not difficult to count to 60.  It is not difficult to count 60000 msec as 1 min too.

  • Hi,

    you can also use the Real-Time-Clock code library  (http://focus.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=slaa290) if you have problems in coding it on your own.

    Rgds
    aBUGSworstnightmare

  • Hi
    I am writing a software that will read 3 ADC, the results of 2 of them will be used all the time, but I want it to compute the result from the 3rd one every 5 minutes. I don't care if the results of the 3 are updated all the time , all I care is to be able to place the result of the 3rd every 5 minutes .

    Can anybody help ?

    Thanks

     

  • Then you have two options:
    1) you can just convert the third channel all 5 minutes. This requires the converison process to be started and the ADC to be reconfigured all the time
    2) you just compute all three channels each minute and discard 4 of 5 results. It will perhaps take a few microjoules for the unnecessary conversion, but the program will be less complex. And the additional code will take some energy too, even if likely not as much)

  • Hi Jens-Michael

    Thank you for your help. I kind of got the sapling from the ADC under control. What I am having some difficulties is how I am going to set the time to sample every 5 minutes ? Can you give me some suggestion ?

    Thanks

     

  • There are several ways. You can sample continuously and just use the results every 5 minutes. Depending on the delay it may or may not be a noticeable waste of energy.

    Then you can use teh CCR units to control the ADC conversion. The CCR will (if set up properly) set and reset its OUT bit and this signal can be used to start a conversion sequence. However, the reference needs to be on all the time (which is the major part in current consumption) since the ADC won't wait for the reference to settle before starting the conversions.
    If you select a slower ADCCLK for the conversion and teh sampling timer, and select a long S&H time, it might still work. In this case, the reference needs to be set in auto mode (switched on as soon as required). This is supported on MSPs with REF module for the reference (REFON bit), but I'm not sure about other MSPs (especially those with ADC10).
    Once the conversion is done, the ADC ISR is called and you can work with the results.

**Attention** This is a public forum