Searching \ for '[PIC]:16bit timer and large lookup table 16f62x' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/time.htm?key=time
Search entire site for: '16bit timer and large lookup table 16f62x'.

Exact match. Not showing close matches.
PICList Thread
'[pic]:16bit timer and large lookup table 16f62x'
2003\07\26@173156 by Kevinhoward

picon face
Hi all,

Using a 16F628-I need to use the 16 bit timer1 prescaled to 8,  and further
divided,the  value to be used in a large lookup table (app2000 values)

HELP!
Being only 8 bit Is it possible to get the tmr1l x tmr1h  value to a lookup
table?

e.g if the  tmr1l x tmr1h value equates to d.1800 how do I calculate tmr1l x
tmr1h  store and get this to point to line 1800 of the lookup table?

I have used small tables with tmro but can't seem to work this one out!

Any help or pointers in the right direction greatly appreciated!

Thanks in advance

Kev

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\07\26@174850 by Olin Lathrop
2003\07\26@175519 by

picon face
With that size of tables, you are soon running out of
prog memory on the 16F628. Could you be more specific ?

What is "app2000" ?

What do you expect to "find" in line 1800 of the table
and how does this relates to the value in tmr1h:tmr1l ?

What is the clock source for tmr1 ?

Or, more specificly, what are you trying to do ?

Jan-Erik.

spam_OUTKevinhowardTakeThisOuTspamAOL.COM wrote:
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\07\26@194241 by Jinx

face picon face
> Being only 8 bit Is it possible to get the tmr1l x tmr1h  value to
> a lookup table?

It sounds like you need to be putting (TMR1H + the high byte of the
table's base address) into PCLATH. It's the same as you'd do for
256-byte tables except using PCLATH to access more locations.
I haven't done this on the 628, only on the 877 (which can read its
own memory without RETLW) so I can't offer a working example
but you can try here

http://www.piclist.com/techref/microchip/tables.htm

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\07\27@074601 by Kevinhoward

picon face
Hi,

I am  measuring the time period of an accelerating spindle which can reach
anwhere from 600rpm to 25000rpm in a matter of seconds although it could be much
slower!

TMR1 is from  4meg resonator from the 628
Table will have about 1000 lines (not app 2000 as my original post!)
The idea being TMR1 will give a more accurate value without rolling over.

The table will determine a delay period for another system

Using TMRO does not give me accurate enough steps at low speed.

Thanks again

Kev



--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\07\27@084129 by Jinx

face picon face
> I am  measuring the time period of an accelerating spindle which
> can reach anwhere from 600rpm to 25000rpm in a matter of
> seconds

Even the fastest speed is still quite a long time for the PIC @ 4MHz

1,000,000 / (25,000 / 60) = 2400us / rev or 2400 instruction cycles

and resolution is being reduced by the /8 pre-scaler

> Table will have about 1000 lines (not app 2000 as my original post!)

Are 1000 really necessary ? Why not 256 ? (bearing in mind the p/s)

> The idea being TMR1 will give a more accurate value without rolling
> over

> Using TMRO does not give me accurate enough steps at low speed

How are you detecting the revs ? If using INTF for example and given
the length of time available to process INTF, it would be quite possible
to use TMR0 and count any rollovers in RAM (which obviously becomes
your high byte to use with PCLATH). As both timers increment on the
internal clock, in this application TMR0 is as "accurate" as TMR1

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\07\27@143043 by Kevinhoward

picon face
Hi,

      Using tmro sounds easier but I haven't worked out how to actually add
how many times tmro has overflowed ff's to the table-(as you will have guessed
I am still on the learning curve!!!)

If I used TMRO;

p1       btfsc     pulse1               ;start
         goto       p1
         clrf        tmro
         bcf        intcon,2           ;clear tmro and intcon,2

p2       btfsc     intcon,2
          call      oflowcount           ;stores nuber of times tmro has
overflowed
          btfsc    pulse2              ;end time
          goto     p2
          movf     tmro,w
          movwf  time              ;tmro value now stored in time

workout
         movf       time,w              ;tmro value
         call        table1
         movwf     timedelay           ;tmro value now stored in time delay
         goto        rest of program

oflowcount
      btfss     intcon,2
      return
      incf       overflow          ;number of times tmro has overflowed
stored here
      bcf       intcon,2
      return

;how can I add number of ff rollovers as stored in overflow to the table?

table1                      ;750-1000 lines
      addwf   pcl,f
      retlw     .
      retlw     .
;etc

Thanks again

Kev


--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\07\27@144523 by

picon face
I think you need a number of 256 value tables and then
"call table1", "call table2" and so on depending on
the actual number in "overflow".        Each table taking
care of one 256 byte sequence each.

Another thing, do use the pre-defined symbols for
the flags in the SFRs, like "bcf intcon, t0ie"
instead of "bcf intcon, 2".
The code is much easier to read that way.

Another different solution to this problem would
be to store the full "table" in some external memory
like a serial EEPROM. The value in "overflow" would
then just be the address bits 8 and 9. Address bits
0 to 7 would of course be the final tmr0 value. That
way it would also be easier to update the table in the
field, if needed.

And, a big *AND*, it's tmr0, not tmro !!

Jan-Erik.


{Original Message removed}

2003\07\27@221040 by Jinx

face picon face
> ;how can I add number of ff rollovers as stored in overflow to the table?
>
> table1                      ;750-1000 lines
>        addwf   pcl,f
>        retlw     .
>        retlw     .
> ;etc

I've just tried a quick test with this and it seems to work. I wasn't sure
if it would, not having used big tables on the F628 before. Try it and
monitor program flow with Watch

         movlw   0x04              ;base address high byte
         addwf   overflow,w     ;add number of blocks offset
         movwf   pclath
         movf    time,w             ;offset within block
         call     table

........rest of code

org 400h                     ;Table start address

table   addwf  pcl    ; w = value in "time"
                                ;also writes PCLATH into PCH
                                ;causing a jump ahead of 256 bytes

        retlw  data000
        retlw  data002
        ........
        ........
        retlw  data999

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\07\27@221909 by Jinx

face picon face
Just correcting the "jump ahead" comment

> table   addwf  pcl    ; w = value in "time"
>                                  ;also writes PCLATH into PCH
>                                  ;causing a jump ahead of (overflow * 256)
bytes

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\07\28@001407 by Jinx

face picon face
Kevin, if you put the table at 03FF then this will access the data
you want from (overflow*256)+time (I think, I hope). The 0400
example I gave you before can go all screwy when time=0 and
boundaries

2nd time lucky

        movf   overflow,w
        addlw  0x04
        movwf  pclath
        movf   time,w
        call   table

        rest of code

org 0x3ff

table    addwf  pcl

        retlw  data000
        retlw  data001
        .......
        .......
        retlw  data999

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...