Forums

real-time clock in code composer

Started by guus_hiddink January 20, 2016
On 4.2.16 17:35, Nikola Gvozdenovic wrote:
> On Friday, January 29, 2016 at 10:46:04 PM UTC+1, Tim Wescott wrote: >> On Thu, 28 Jan 2016 18:13:24 -0800, John Speth wrote: >> >>>> I need to write code that works on development board RS MSP430F5438A >>> >>> Hardly anybody writes code from scratch these days. Chip vendors >>> usually supply plenty of code to get customers started. It's rarely >>> high quality but it goes a long way to getting you started. >>> >>> Use Google to find "MSP430F5438 Experimenter Board". You'll find: >>> >>> http://www.ti.com/tool/msp-exp430f5438 >>> >>> Scour that web page for example code. There should be everything you >>> need. Code development is impractical without HW with which to test. If >>> your teacher is grading you on working code and your grade can mean the >>> difference between getting a pro job or not in the future, I recommend >>> you find $175 and buy the board. Otherwise, find a loaner. >>> >>> Failing all that, at least get your project building successfully in >>> CCS. I can guarantee it won't work the first time you download it to >>> the target. You would iterate possibly hundreds of times. That's how >>> most people write firmware. >>> >>> You've got a lot of work to do and a huge learning curve to climb. We've >>> all been there. Good luck. >> >> I get a sense, perhaps erroneous, that the guy isn't in the US. There >> are places where $175 is quite prohibitive. >> >> It may be that all the instructor wants is for people to dig up example >> code, compile it, load it, and try it. This is actually not a trivial >> thing for a really basic class, or at least not for a first experiment in >> a really basic class. >> >> -- >> >> Tim Wescott >> Wescott Design Services >> http://www.wescottdesign.com > I wrote code for my application, two versions. First one uses the interrupt routine for buttons,and second one periodically checks the state of pins where are buttons. I have question for first version. Can I use flags as conditions for each button in interrupt routine,e.g. #pragma vector=PORT2_VECTOR > __interrupt void port2handler(void) > { > if(P2IFG & BIT4) // button for settings is pressed > { // something to do > P2IFG &= ~BIT4; // clear flag} > } > > I will test the project 2/6/2016, so I don't know now if that works. Is that way of interrupt routine make sense? Thanks
A button is an unfriendly thing from the processor viewpoint. When closing, it always bounces for some milliseconds and feeds multiple closing signals to the processor. Most buttons do the same on opening. You'd be better off if you polled the button in regular intervals and trusted the output when there are sufficiently many same states read after each other. The common method is to have the intervals from a timer interrupt. -- -TV
Here is a link to examples how to deal with bouncing on buttons/switches

https://www.ikalogic.com/de-bouncing-circuits/

Maybe Nikola will look into it and implement one of solutions.

--
AM

On Thursday, February 4, 2016 at 1:01:32 PM UTC-5, Tauno Voipio wrote:
> On 4.2.16 17:35, Nikola Gvozdenovic wrote: > > On Friday, January 29, 2016 at 10:46:04 PM UTC+1, Tim Wescott wrote: > >> On Thu, 28 Jan 2016 18:13:24 -0800, John Speth wrote: > >> > >>>> I need to write code that works on development board RS MSP430F5438A > >>> > >>> Hardly anybody writes code from scratch these days. Chip vendors > >>> usually supply plenty of code to get customers started. It's rarely > >>> high quality but it goes a long way to getting you started. > >>> > >>> Use Google to find "MSP430F5438 Experimenter Board". You'll find: > >>> > >>> http://www.ti.com/tool/msp-exp430f5438 > >>> > >>> Scour that web page for example code. There should be everything you > >>> need. Code development is impractical without HW with which to test. If > >>> your teacher is grading you on working code and your grade can mean the > >>> difference between getting a pro job or not in the future, I recommend > >>> you find $175 and buy the board. Otherwise, find a loaner. > >>> > >>> Failing all that, at least get your project building successfully in > >>> CCS. I can guarantee it won't work the first time you download it to > >>> the target. You would iterate possibly hundreds of times. That's how > >>> most people write firmware. > >>> > >>> You've got a lot of work to do and a huge learning curve to climb. We've > >>> all been there. Good luck. > >> > >> I get a sense, perhaps erroneous, that the guy isn't in the US. There > >> are places where $175 is quite prohibitive. > >> > >> It may be that all the instructor wants is for people to dig up example > >> code, compile it, load it, and try it. This is actually not a trivial > >> thing for a really basic class, or at least not for a first experiment in > >> a really basic class. > >> > >> -- > >> > >> Tim Wescott > >> Wescott Design Services > >> http://www.wescottdesign.com > > I wrote code for my application, two versions. First one uses the interrupt routine for buttons,and second one periodically checks the state of pins where are buttons. I have question for first version. Can I use flags as conditions for each button in interrupt routine,e.g. #pragma vector=PORT2_VECTOR > > __interrupt void port2handler(void) > > { > > if(P2IFG & BIT4) // button for settings is pressed > > { // something to do > > P2IFG &= ~BIT4; // clear flag} > > } > > > > I will test the project 2/6/2016, so I don't know now if that works. Is that way of interrupt routine make sense? Thanks > > > A button is an unfriendly thing from the processor viewpoint. > When closing, it always bounces for some milliseconds and feeds > multiple closing signals to the processor. Most buttons do the > same on opening. > > You'd be better off if you polled the button in regular intervals > and trusted the output when there are sufficiently many same > states read after each other. The common method is to have the > intervals from a timer interrupt. > > -- > > -TV