• AVR Freaks

AnsweredHot!Timer0 16 bits

Page: < 123 Showing page 3 of 3
Author
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/02 12:34:22 (permalink)
0
I had forgotten that one. i suppose it is off config 2L is h'2d'. Ho it is wrong it would be 2E
Thank you 1and0. I remake. Regards.
#41
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/02 13:09:54 (permalink)
0
I confused config 3L is h'9F' bits 6-5 = 00 wdt disable. I dont known how to verify this. Program runs 3 minutes, more than 141millions cycles.
post edited by Chabb - 2019/12/02 13:15:24
#42
1and0
Access is Denied
  • Total Posts : 10223
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/12/02 13:23:33 (permalink) ☼ Best Answerby Chabb 2019/12/05 02:09:34
+1 (1)
Chabb
I confused config 3L is h'9F' bits 6-5 = 00 wdt disable. I dont known how to verify this.

In Post #36 I said "I'm not going to criticize your program," but you really should use symbol names for your config bits; for example,
    CONFIG WDT = OFF

 

Program runs 3 minutes, more than 141millions cycles.

I have never run the Simulator in MPLAB X for more than a few seconds at a time ;) so I cannot answer your question.
 
However, I've run the Simulator in MPLAB 8 for over 12 hours (slow computer) performing an exhaustive test of an assembly routine for 32-bit binary to BCD conversion for a 16-bit PIC device.
post edited by 1and0 - 2019/12/02 13:26:08
#43
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/02 15:39:04 (permalink)
0
Ok for symbolic config it is not well explain in the data sheet-40001869D.pdf. je ne retrouve rien at 300000hex.
exactly the same program was running perfectly on a 18f2520 under mplab 8.91 except addresses of sfr registers and 2520-fosc 32Mhz  25k42-fosc 64Mhz. that is true I am not sure of my config. I will try to follow your conseils. tank you for your help. 1 and 0 = 1! best regards.
#44
ric
Super Member
  • Total Posts : 25230
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: Timer0 16 bits 2019/12/02 15:49:43 (permalink)
0
Are you using MPLABX?
If yes, the "Set Configuration bits" window handles it all for you, and generates the appropriate code pasr source.
 

exactly the same program was running perfectly on a 18f2520

The K42 is a vastly different chip to your old 18F2520, so some changes are to be expected.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#45
dan1138
Super Member
  • Total Posts : 3312
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/02 18:28:28 (permalink) ☄ Helpfulby Chabb 2019/12/05 02:47:59
+1 (1)
@Chabb,
Chabb
Ok for symbolic config it is not well explain in the data sheet-40001869D.pdf. je ne retrouve rien (I can not find anything) at 300000 hex.

exactly the same program was running perfectly on a 18f2520 under mplab 8.91 except addresses of sfr registers and 2520-fosc 32Mhz  25k42-fosc 64Mhz. that is true I am not sure of my config. I will try to follow your conseils. tank you for your help. 1 and 0 = 1! best regards.

From when MPLAB 8.91 was current to now with MPLABX v5.xx there have been a lot of changes to the tool chain.

Syntax that was once acceptable will no longer work.

The code you posted is perhaps the worst example of PIC18F assembly language coding I have yet seen on this forum.

For example this method does not set the configuration words for a PIC18F25K42:
    org 300000       ;configuration of the chip
_config1l = h'8f'     ;internal clock. 64Mhz.
_config1h = h'd5'
_config2l = h'2d'
_config2h = h'c7'
_config3l = h'9f'
_config3h = h'ff'
_config4l = h'ff'
_config4h = h'df'
_config5l = h'ff'


This method does set the configuration words for a PIC18F25K42:
    org 300000       ;configuration of the chip
 __config h'300000',h'8c'     ;internal clock. 64Mhz.
 __config h'300001',h'd5'
 __config h'300002',h'2d'
 __config h'300003',h'e7'
 __config h'300004',h'9f'
 __config h'300005',h'ff'
 __config h'300006',h'ff'
 __config h'300007',h'df'
 __config h'300008',h'ff'
but this method is deprecated for MPLABX.

Also note that the values for CONFIG1L and CONFIG2H have been changed.
The setting for CONFIG1L turns off the external oscillator, the setting for CONFIG2H turns off DEBUG mode. DEBUG mode should not be enabled by the configuration words defined in the source code. When using In-Circuit-Debug let the IDE control when the DEBUG mode is enabled.

Using better style when coding in assembly is essential.

The way you have implement macros will cause anyone that may want to help you to avoid contributing to this thread in a positive way.

You code frightens me a lot.
#46
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/05 03:09:24 (permalink)
0
1and0 you are right my config is illegal then inoperative, debugger does not signal any error. After redo no more untimely initialize occurs.
dan1138 thank you my config is deprecated but now it works.
What is wrong implementing macros Where to find the syntax of Mpasm language? I use an old guide DS51025. regards.
#47
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/10 10:07:13 (permalink)
0
hello members. programming pic 18f25k42 under mplabx v5.30.
question: Is it possible to use timer1 as a counter without any clock but increment this counter bye the incfnz instruction? how to proced? thank you .
#48
dan1138
Super Member
  • Total Posts : 3312
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/10 10:41:22 (permalink)
+2 (2)
Chabb
hello members. programming pic 18f25k42 under mplabx v5.30.question: Is it possible to use timer1 as a counter without any clock but increment this counter bye the incfnz instruction? how to proced? thank you .

This doesn't seem like a good idea to me.

Please explain in detail what you want to accomplish by incrementing just the low byte of TIMER1.
#49
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/10 13:05:28 (permalink)
0
Thank you for your quick response. I would like to use timer1 in 16 bits mode preload tmr1h increment tmr1low bye infsnz then bra...if timer1=0
This timer is "read-write" Is it possible?
like I explained the last week my program did run in a Pic18f2520; 32Mhz. Now I program 18f25k42 64Mhz.
whit 18f2520 I used Several counters counting 0 to 255; Whit 18f25k42 64Mhz counts are 255x2 then need a 9bits counter.
post edited by Chabb - 2019/12/10 13:24:01
#50
ric
Super Member
  • Total Posts : 25230
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: Timer0 16 bits 2019/12/10 13:09:48 (permalink)
0
Incrementing TMR1L in that way will NOT increment TMR1H on rollover. i.e. it just does an 8 bit increment on the low register, not a 16 bit increment of the whole timer.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#51
1and0
Access is Denied
  • Total Posts : 10223
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/12/10 13:11:37 (permalink)
0
Chabb
Thank you for your quick response. I would like to use timer1 in 16 bits mode preload tmr1h increment tmr1low bye infsnz then bra...if timer1=0
This timer is "read-write" Is it possible?

When Timer1 is turned off, TMR1L and TMR1H can be used like any other data memory. That being said, as Dan has asked, what are you trying to achieve by manually incrementing TMR1:

infsnz  TMR1L
incf    TMR1H

#52
ric
Super Member
  • Total Posts : 25230
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: Timer0 16 bits 2019/12/10 13:15:29 (permalink)
0
1and0's code will do a 16 bit increment, and the Z flag will be set afterwards if the 16 bit value is zero, but you then have to use another skip instruction again if you want to do a conditional jump, so you've gained nothing from using any other general purpose register. There's no benefit in using the timer registers.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#53
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/10 13:31:39 (permalink)
0
I have complited my post to said why I am doing that because i need a 9 bit counter.
#54
ric
Super Member
  • Total Posts : 25230
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: Timer0 16 bits 2019/12/10 13:34:44 (permalink)
0
Please don't change questions after they get answers.
You still haven't clearly explained what you are trying to do.
If you want the timer to roll over after 512 counts, preload it with 0xFE00.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#55
1and0
Access is Denied
  • Total Posts : 10223
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/12/10 13:51:46 (permalink)
0
Chabb
I have complited my post to said why I am doing that because i need a 9 bit counter.

If you want to slow your Timer1 interrupt interval because Fosc is doubled, then just simply double either the prescaler or the postscaler of Timer1.
#56
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/10 13:54:01 (permalink)
0
Ok Ric you have post a response during the time I re edited my message You work quickly than me. I understand I have to preload whit FE00. My problem is How to implement this counter in t1con and t1gcon; may be more other things to do?
#57
Chabb
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/10 14:10:47 (permalink)
0
1 and 2 If I double the prescaler it would be the same if fosc is 32 Mhz. it is very complicated to explain here what I  try to do. If you or anybody Wish really see what I do please see on my site at this adress :
bernard.chabbert.pagesperso-orange.fr
On the welcome page click on BoiteaMus then you can download "Electronic music box .doc and/or Boitamus2.asm. At 32Mhz some notes range4 are not acurate in frequence. This is why I need 64Mhz.
post edited by Chabb - 2019/12/11 03:36:58
#58
ric
Super Member
  • Total Posts : 25230
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: Timer0 16 bits 2019/12/10 14:51:17 (permalink)
0
Working with timers is trivial, not complicated.
Rather than agonising how you think you should solve your problem, just say what you want to do.
You're getting yourself tangled up over trivialities.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#59
Page: < 123 Showing page 3 of 3
Jump to:
© 2020 APG vNext Commercial Version 4.5