• AVR Freaks

AnsweredHot!Timer0 16 bits

Page: < 12345 > Showing page 4 of 5
Author
mbrowning
USNA79
  • Total Posts : 1791
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: offline
Re: Timer0 16 bits 2020/02/08 07:51:41 (permalink)
+1 (1)
Alt-Shift-5 (or menu item Windows->Debugging->Breakpoints) to open the Breakpoint window. Right click within the window, and delete all. Or just delete selected breakpoints or disable them.
#61
Chabb
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/09 08:05:52 (permalink)
0
Thank you Mbrowning where can I find this procedure?
Other problem: instruction BTG does not work on a port. I.E    btg portb,2  portb is not modify. That worked in mplab8.
#62
ric
Super Member
  • Total Posts : 28006
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Timer0 16 bits 2020/02/09 12:08:21 (permalink)
+2 (2)
Do NOT use bit instructions on PORTx registers.
Do it on the matching LATx register.
I also suspect you have the pin in analog mode, so it always reads as zero.
 
 

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!
#63
Chabb
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/10 05:57:13 (permalink)
0
Thank you Ric. btg on latb makes an error. Precision : Mplabx 5.30 Pic 18f25k42
In my program in assembler :
init   clear   portb     ;portb = 00
  .
  .
       btg      portb,1  ;portb = 02   OK
   .
   .                           ;60 instructions
       btg      portb,1   ;portb = 02 not modify.
The behaviour off the BTG instruction is exactly the same as BSF instruction. However btg funtions correctly
on a file register.
#64
1and0
Access is Denied
  • Total Posts : 10999
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2020/02/10 06:49:41 (permalink)
+2 (2)
Did you set that pin to output? Did you disable any and all analog features on that pin? As always, read from PORTx and write to LATx!!!
#65
Chabb
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/10 07:47:58 (permalink)
0
Thank you Ric & 1 and0 Yes Ansela is 00; anselb was FF. I dont now why I never access this register.
Btg portb,1 work correctly after clear anselb.
#66
ric
Super Member
  • Total Posts : 28006
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Timer0 16 bits 2020/02/10 12:09:59 (permalink)
+2 (2)
Chabb
Thank you Ric & 1 and0 Yes Ansela is 00; anselb was FF. I dont now why I never access this register.
Btg portb,1 work correctly after clear anselb.

It will until you get too much load or capacitance on the pin, then it will fail again.
WHAT error did you get when you tried to use LATB instead of PORTB?
That IS the correct register to use.
 

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!
#67
Chabb
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/12 02:54:21 (permalink)
0
When I tried to toggle "btg" latb,1 a window open ERROR cannot get privilegied access... I dont remember
then impossibility to save asm nor to close mplab.I dont find this error in mplab help.
This error does not more appear after clear anselb.
There is no obligation to write to a portx through the latx register. Data sheet 40001869D section 16 sais :
A write operation to the latx has the same effect as a write to the corresponding portx register.
Thank you for your help my program now runs correctly.
#68
DaveWeckl
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2016/08/22 07:45:58
  • Location: 0
  • Status: offline
u 2020/02/12 16:00:50 (permalink)
0
ups...
post edited by DaveWeckl - 2020/02/12 16:11:20
#69
dan1138
Super Member
  • Total Posts : 3730
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/12 21:11:39 (permalink)
+1 (1)
ChabbData sheet 40001869D section 16 sais :A write operation to the latx has the same effect as a write to the corresponding portx register.

That is what the data sheet says, and it is true as long as the PIC instruction is a WRITE only instruction. 

The BTG instruction is NOT a WRITE only instruction. 

The BTG instruction is a READ-MODIFY-WRITE instruction. (BTG is not the only one) 

The read portion of this instruction samples the state of all of the PORT bits then toggles the bit selected bit then writes ALL of the port bits. 

The PIC18F part you are using can execute BTG instructions faster the the GPIO pin driver can cause the physical change of the bit before the next BTG instructions read phase completes. This results in the next BTG instruction reading the wrong state of a previously changed bit. 

This is why any READ-MODIFY-WRITE instruction that affect GPIO bits should only access the LAT register of a PORT.
post edited by dan1138 - 2020/02/13 00:14:53
#70
1and0
Access is Denied
  • Total Posts : 10999
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2020/02/13 03:52:29 (permalink)
+2 (2)
dan1138
That is what the data sheet says, and it is true as long as the PIC instruction is a WRITE only instruction. 

Just curious (I've not checked the PIC datasheet yet ;), which instruction is a write-only instruction?  Most instructions, even MOVWF, perform a read on Q2, a process (modify) on Q3, and a write on Q4.
#71
Chabb
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/16 07:41:53 (permalink)
0
thank you Dan1138 for this explanation but now I can sai certainly: Btg portb,1 or portb,2 or portb,3 (I use this instruction millions times in my program) functions correctly. See 1and0 analyse.
I spend many hours to finalyse my program because in mplabx ide for pic 18f25k42 I have big difficulties
to follow the contains of the file registers and timers (16 bits) that are not displayed. and other disfunctions.
#72
1and0
Access is Denied
  • Total Posts : 10999
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2020/02/16 07:58:50 (permalink)
+1 (1)
Chabb
... but now I can sai certainly: Btg portb,1 or portb,2 or portb,3 (I use this instruction millions times in my program) functions correctly. See 1and0 analyse.

Follow this simple rule and you'll have less headache: write outputs to LATx, and read inputs from PORTx.
#73
dan1138
Super Member
  • Total Posts : 3730
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/16 11:54:57 (permalink)
+3 (3)
1and0
Just curious (I've not checked the PIC datasheet yet ;), which instruction is a write-only instruction?  Most instructions, even MOVWF, perform a read on Q2, a process (modify) on Q3, and a write on Q4.



For the PIC18F the MOVWF, MOVFF, and MOVFFL are write only forms as far as the destination register is concerned.
 
The 8-bit PICs all use a 4 state micro-cycle of Decode-Read-Operate-Write. The distinction for what I am calling write only instructions is that the destination is not read during any of the Q states.
 
It would seem that until chabb actually encounters the R-M-W problem in the real world he is certain there is no problem. In this case only burnt fingers will teach the lesson.
#74
Chabb
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/19 03:00:26 (permalink)
0
Ok Dan thank you for warning me I will put on gloves. Currently I only work in MPLABX in simulation and considering the problems of viewing files, timer, ports it is a feat.
My program is now ready and running properly in MPLABX thanks in part to the help I received from members of this forum which I thank. I will now tackle the programming of the Pic18f25k42 chip. The behavior of the program in real must be the same as in MPLABX otherwise it would be hopeless and for me MPLABX would be definitively unusable. I will keep you informed of the results obtained.
Regards, Chabb
 
#75
ric
Super Member
  • Total Posts : 28006
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Timer0 16 bits 2020/02/19 06:04:55 (permalink)
+4 (4)
Chabb
.... The behavior of the program in real must be the same as in MPLABX otherwise it would be hopeless and for me MPLABX would be definitively unusable. I will keep you informed of the results obtained.

Experienced programmers will be laughing at this point.
Simulations are NEVER 100% accurate of what you will find in the real world.
That is where things like RMW are lurking, waiting to trap the trusting.
 

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!
#76
1and0
Access is Denied
  • Total Posts : 10999
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2020/02/19 07:23:39 (permalink)
+2 (2)
ric
 
Experienced programmers will be laughing at this point.
Simulations are NEVER 100% accurate of what you will find in the real world.
That is where things like RMW are lurking, waiting to trap the trusting.

I did get a chuckle out of it. ;)  As Dan said, OP will just have to learn about it the hard way.
 
#77
Chabb
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/02/20 06:39:36 (permalink)
0
I'm not saying "The simulation is 100% accurate" I'm saying "it would be" otherwise the tool is unusable.grin: grin
#78
1and0
Access is Denied
  • Total Posts : 10999
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2020/02/20 08:17:03 (permalink)
+2 (2)
Chabb
I'm not saying "The simulation is 100% accurate" I'm saying "it would be" otherwise the tool is unusable.grin: 

The Simulator is USELESS as far as RMW is concerned, because that is a hardware dependent issue.
#79
Chabb
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2020/03/07 09:15:03 (permalink)
0
Hello members. I need help.
I was programming a Pic18F25K42. Now I have an Hex file.
Please how to write this hex file into the Pic Flash memory; wich Hardware, wich software?
Before I had a Jdm programmer and winpicpgm to program pic 18f2520. This tool does not support pic 18f25k42.
Thank you
 
#80
Page: < 12345 > Showing page 4 of 5
Jump to:
© 2020 APG vNext Commercial Version 4.5