4 Channel Timer/Counter

Post details of your projects here.
danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: 4 Channel Timer/Counter

Post by danlee58 »

I have code for a Coridium SuperPro board from a previous project. I used the SuperPro on that project because I needed a DAC output. I could save some money, by using a ProPlus on this project. Will my setup code be different from the SuperPro? It may be worth the extra money, if I can reuse some code.



olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: 4 Channel Timer/Counter

Post by olzeke51 »

Hi, - what code size are you anticipating ??
Super has - 128k user code space (10,000 Instructions)
16k user data
Plus has - 20k user code space (1600 Instructions)
5k user data
*
Plus has no +5v available
Plus has no DAC
*
no apparent special files in Basiclib, no #ifdef for the different chips in LPC17xx.bas
pin assignments are the same (an issue I had between two different chipset namings - NXP improvement)
?
Same amount of Timers ?? I didn't look at the spec sheets!
*
Looks like a go from here -- Olzeke51

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: 4 Channel Timer/Counter

Post by danlee58 »

I'll stick with the SuperPro. The money savings for the ProPlus is not worth the risk that I'll need something that isn't available with the ProPlus for a single quantity. If I ever have a market for this, I can look at the ProPlus again.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: 4 Channel Timer/Counter

Post by danlee58 »

I need 4 Match Pins. P1.28 is Mat0.0, P1.25 is Mat1.0, P0.10 is Mat 3.0, but there is no Arduino compatible pin for Match2 Register.

How can I get 4 Match Register output pins?

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: 4 Channel Timer/Counter

Post by danlee58 »

I'm only going to use 2 Match pins. I'll use P1.28, and P0.10. I'll multiplex the outputs and double the duty cycle of MR0.0, and MR3.0.

I need to use Timer1 as a Capture Timer. I want to start Timer1 on the falling edge of P1.18, and capture TC1 on the rising edge of P1.18. Should I just poll & clear TC on the falling edge, then Interrupt on the rising edge & reset?

Can I poll P1.18, when it's used as a Capture pin?

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: 4 Channel Timer/Counter

Post by basicchip »

You can always read the state of an input even if it is used as special purpose pin.

You should be able to use the capture hardware to reset the timer or do it on an interrupt.

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: 4 Channel Timer/Counter

Post by basicchip »

There are many more match pins, you can jumper over to them to connect to Arduino pins for a shield.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: 4 Channel Timer/Counter

Post by danlee58 »

I need a Low True output on Match 0.0 (P1.28), and Match 3.0, (P0.10).
How can I make the External Match Outputs Low true?

How long does the Match Pin stay true?

Should I set Tx_MCR to 0x040 to stop the timer, until I start it again, so the Match Pin stays True?

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: 4 Channel Timer/Counter

Post by basicchip »

I don't really know what you are trying to do, but most of the time I reset the counter on a match, if you need to change the next match time then you should generate an interrupt on match as well and reprogram the registers.

As for the match output pin, you can use the match to set the pin high or low or to toggle or do nothing. It will stay in that state until the next match.

danlee58
Posts: 210
Joined: Thu Jan 17, 2013 2:29 am

Re: 4 Channel Timer/Counter

Post by danlee58 »

I generate an Interrupt on Match & set Tx_MCR to 0x40 to stop the timer. The external match pin should stay True until I reset the timer elsewhere in the program.

I'm still not sure how to get the External Match pin to go Low True on a match. Do I have to output a Zero in my interrupt routine?

Post Reply