New Micros, Inc  

Go Back   New Micros, Inc > IsoMax™ - ServoPod™ - IsoPod™ - MinPod™ - PlugaPod™ - TiniPod™
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-30-11, 12:18 PM
Norse Norse is offline
Registered User
 
Location: Toronto, Canada
Posts: 82
Timer B Oflag

I like the timers and their flexibility.
However, I am now trying to figure out how to use the OFLAG as an output which is connected to an external device.
I post my question to avoid pulling an ISOPOD out of a system for testing.
I am to count 200 pulses on TB0 (as set up in the CMP1 register) and then output a pulse, preferably on the IND1 pin. My understanding from the DSP56F800 is that I should be able to assign a timer pin as an output.
Any thoughts are welcome.

Cheers and thanks.

Per
Reply With Quote
  #2  
Old 05-30-11, 03:45 PM
RMDumse RMDumse is offline
Moderator
 
Posts: 1,406
Hey Per, Good to hear from you.

I like the timers and their flexibility, too. Best, most flexible timers I've ever found.


Quote:
I am to count 200 pulses on TB0 (as set up in the CMP1 register) and then output a pulse, preferably on the IND1 pin.


Guess I need to ask the depth of your question, because if you are asking can you set the timer output high or low, yes, that's easy. IND1 pin shares the TB2 pin.

So when you get your 200 count flag, you could just TB2 ON TB2 OFF to generate a pulse.

The deeper question might be, how can I generate a timed pulse width for the output.

The deeper question yet might be how do I generate a timed pulse width output in hardware.

But the deeper questions are a bunch of work to write up, and I want to be sure the simple answer is not what you're looking for first.

Last edited by RMDumse : 05-30-11 at 06:27 PM.
Reply With Quote
  #3  
Old 05-30-11, 04:35 PM
Norse Norse is offline
Registered User
 
Location: Toronto, Canada
Posts: 82
Hi Randy.
Yep, still around... :-)
Trying to solve some technical problems before proceeding with an idea....
The core question for me is to be able to generate the pulse every 200 count by using the hardware... Set registers etc. and rely on the timers to do the work. I am using the Group A for measuring pulse-width for various purposes. That works great.
Now, looking at the Control register for TimerB2 (IND1); If I select the primary counter input as pin 0 in the B group and enable the OFLAG output, will the IND1 become the output? Now that would be too simple.....

Cheers,

Per
Reply With Quote
  #4  
Old 05-30-11, 06:31 PM
RMDumse RMDumse is offline
Moderator
 
Posts: 1,406
I think the answer to your question is basically, yes, it is that simple. From the manual:

14.5.3 OFLAG Output Signal
The primary output of each Counter/Timer is the output signal OFLAG. The OFLAG output signal can be set, cleared, or toggled when the counter reaches the programmed value. The OFLAG output signal may be outputted to an external pin shared with an external input signal. The OFLAG output signal enables each counter to generate square waves, PWM, or pulse stream outputs. The polarity of the OFLAG output signal is selectable.
Reply With Quote
  #5  
Old 05-31-11, 04:05 AM
RMDumse RMDumse is offline
Moderator
 
Posts: 1,406
I'm still concerned about the output pulse width. Your options as listed above are setting or clearing the output pin, or toggling the output pin.

If you want to run without processor intervention, then you'll need to toggle the pin high and toggle the pin low. Essentially you'd be making a "divide by 200" frequency counter. But you'd count 100 and toggle to get the effect.

So it depends on what your desired output is like. If your pulse can be 100 counts high and then 100 counts low, this can be the easier way.

But if you want a shorter pulse, then you'd have to work with (perhaps) the PWM mode.
Reply With Quote
  #6  
Old 05-31-11, 07:36 AM
Norse Norse is offline
Registered User
 
Location: Toronto, Canada
Posts: 82
Hi Randy,
Your thoughts and ideas are welcome.
All I need is actually just a short pulse every 200 counts and looking at the OFLAG options, I can set it to toggle. The pulse width is not that important as the pulse is only triggering a TTL or CMOS input. The input will vary with a max frequency of 8Khz. My thought here is that there is hardware available capable of doing the work rather than taking up memory space and processing time... "Set and forget...." I don't know how big the code will become at this point so I delegate early on.... I will probably use all the timers available and then some for various functions...

I currently have 2 ISOPODs connected with CAN and it is quite amazing how fast the communication is... No lags that I can see. Once I get past the prototype stage then I will need to create some PCB motherboards and add some PODs, linked by CAN....

Cheers,

Per
Reply With Quote
  #7  
Old 05-31-11, 05:04 PM
RMDumse RMDumse is offline
Moderator
 
Posts: 1,406
Quote:
Originally Posted by Norse
"Set and forget...."


Okay, you're intent on working me hard.

Let's see if we can figure this as a frequency divider first, and then see if we can figure out how to make the pulse shorter.

First point of information, it's all about CNTRL and STATUS register set up. So let me list all the possiblities first.

Code:
( Here are all the modes for counter for CTRL and STATUS ( CTRL ( 000 ( COUNT MODE NO COUNT ( 001 ( COUNT RISING EDGES OF PRIMARY SOURCE ( 010 ( COUNT RISING AND FALLING EDGES OF PRIMARY SOURCE ( 011 ( COUNT RISING EDGES OF PRIMARY SOURCE WHILE SEC. HIGH ( 100 ( QUADRATURE RISING EDGES OF PRIMARY AND SEC. SOURCE ( 101 ( COUNT PRIMARY SOURCE RISING EDGES, SEC. SPECS. DIRECTION ( 110 ( EDGE OF SEC. SOURCE TRIGGERS PRIMARY COUNT TILL COMPARE ( 111 ( CASCASE COUNTER MODE UP/DOWN ( 0000 ( Counter #0 input pin ( 0001 ( Counter #1 input pin ( 0010 ( Counter #2 input pin ( 0011 ( Counter #3 input pin ( 0100 ( Counter #0 output ( 0101 ( Counter #1 output ( 0110 ( Counter #2 output ( 0111 ( Counter #3 output ( 1000 ( PRIMARY COUNT SOURCE IP/1 ( 1001 ( PRIMARY COUNT SOURCE IP/2 ( 1010 ( PRIMARY COUNT SOURCE IP/4 ( 1011 ( PRIMARY COUNT SOURCE IP/8 ( 1100 ( PRIMARY COUNT SOURCE IP/16 ( 1101 ( PRIMARY COUNT SOURCE IP/32 ( 1110 ( PRIMARY COUNT SOURCE IP/64 ( 1111 ( PRIMARY COUNT SOURCE IP/128 ( 00 ( SECONDARY COUNT Counter # 0 input ( 01 ( SECONDARY COUNT Counter # 1 input ( 10 ( SECONDARY COUNT Counter # 2 input ( 11 ( SECONDARY COUNT Counter # 3 input ( 0 ( COUNT ONCE - 0 REPEATEDLY ( 1 ( COUNT ONCE - 1 ONCE AND STOP ( 0 ( COUNT LENGTH ROLL OVER ( 1 ( COUNT LENGTH COUNT UNTIL COMPARE AND REINITIALIZE ( 0 ( DIR COUNT UP ( 1 ( DIR COUNT DN ( 0 ( COINIT NO FORCE BY OTHER CHANNELS ( 1 ( COINIT FORCE BY OTHER COUNTER WHEN ACTIVE COMPARE ( 000 ( OUPUT MODE, Active while counter is active ( 001 ( CLEAR OFLAG OUTPUT ON SUCCESSFUL COMPARE ( 010 ( SET OFLAG OUTPUT ON SUCCESSFUL COMPARE ( 011 ( TOGGLE OFLAG OUTPUT ON SUCCESSFUL COMPARE ( 100 ( TOGGLE OFLAG USING ALTERNATING COMPARE REG ( 101 ( SET ON COMPARE, CLEAR ON SEC. SOURCE INPUT EDGE ( 110 ( SET ON COMPARE, CLEAR ON COUNTER ROLLOVER ( 111 ( ENABLE GATED CLOCK OUTPUT WHILE COUNTER IS ACTIVE ( STATUS 00 TCF, TCFIE ( 00 TOF, TOFIE ( 00 IEF, IEFIE ( 0 IPS ( 0 INPUT ( 00 CAPTURE DISABLED ( 01 CAPTURE REGISTER OPERATION CAP ON RISING EDGE IF IPS=0 ( 01 CAPTURE REGISTER OPERATION CAP ON FALLING EDGE IF IPS=1 ( 10 CAPTURE REGISTER OPERATION CAP ON FALLING EDGE IF IPS=0 ( 10 CAPTURE REGISTER OPERATION CAP ON RISING EDGE IF IPS=1 ( 11 CAPTURE REGISTER OPERATION CAP ON BOTH EDGE ( 0 MASTER ( 0 EEOF ( 0 VAL ( 0 FORCE ( 0 OPS ( 0 OEN


So as I understand your desired set up, you'll have an input to the timer for other uses (duration of pulse width perhaps) so we'll assume it's coming in on a pin and we'll be counting on every rising edge of it.

So we choose rising edges and counter pin TB0 (or modify to suit):
001 ( COUNT RISING EDGES OF PRIMARY SOURCE
0000 ( Counter #0 input pin

There's no secondary count input needed so 00 is as good as any:
00 ( SECONDARY COUNT Counter # 0 input

We'll want the process of counting to be repeated:
0 ( COUNT ONCE - 0 REPEATEDLY

And run to the comparison of 200 then reinitialize:
1 ( COUNT LENGTH COUNT UNTIL COMPARE AND REINITIALIZE

Might as well count from 0 up:
0 ( DIR COUNT UP

And we don't FORCE any other timers:
0 ( COINIT NO FORCE BY OTHER CHANNELS

For output mode, we'll toggle each compare:
011 ( TOGGLE OFLAG OUTPUT ON SUCCESSFUL COMPARE

So putting the pieces together we get a pattern like this

001
0000
00
0
1
0
0
011

Assembled into binary:

001 0000 00 0 1 0 0 011

or:

0010000000100011

then grouped for easy hex conversion:

0010 0000 0010 0011

Looks like we want a CNTL reg value of

2023

Now to the STATUS

00 TCF, TCFIE
00 TOF, TOFIE
00 IEF, IEFIE
0 IPS
0 INPUT
00 CAPTURE DISABLED
0 MASTER
0 EEOF
0 VAL
0 FORCE
0 OPS
1 OEN

which is an obvious conversion to hex:

0001

More as I think it up...
Reply With Quote
  #8  
Old 05-31-11, 08:39 PM
Norse Norse is offline
Registered User
 
Location: Toronto, Canada
Posts: 82
Hi Randy.
It all works beautifully... We even agreed on the h2023 CTRL setting as I had done that. I made the Status a bit more complex than h1... Made a silly error with the registry offset which threw me off a bit until I realized my typo.
I did a bit of neural surgery and got access to the wires... Hooked up a scope and watched....
It is so simple that I am tempted to file a complaint... :-)
I initially thought of it as more complicated...
By storing new values in the COMP1 registry I could watch the change on the output.... Nice and clean....

Soo, thanks for your help and input.

Cheers,

Per.

Last edited by Norse : 06-01-11 at 12:30 PM.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is On
Forum Jump



All times are GMT -5. The time now is 04:07 PM.


Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.