Author Topic: How to combine TMR0H + TMR0L into a 16 bit variable using XC8  (Read 14445 times)

0 Members and 1 Guest are viewing this topic.

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: How to combine TMR0H + TMR0L into a 16 bit variable using XC8
« Reply #25 on: February 14, 2016, 08:53:07 am »
Getting slightly off topic because DTJ only wanted to read Timer0 in a much simpler way, but here is what WRITETIMER0(counts) becomes:-

 
Code: [Select]
TMR0H=counts>>8,TMR0L=counts&0xFF;

  3FA4    5006     MOVF 0x6, W, ACCESS
  3FA6    6ED7     MOVWF 0xfd7, ACCESS
  3FA8    C005     MOVFF 0x5, 0xfd6

Not quite as compact as handcrafted assembler, but pretty close!
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: How to combine TMR0H + TMR0L into a 16 bit variable using XC8
« Reply #26 on: February 14, 2016, 09:08:26 am »
What XC8 compiler version, mode and optimisation level produced that?
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 627
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: How to combine TMR0H + TMR0L into a 16 bit variable using XC8
« Reply #27 on: February 15, 2016, 01:53:06 am »
XC8 V1.35 in 'free' mode, via MPLAB IDE V8.92

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf