#103 HC08:wrong 16 bytes loading asm result

open
nobody
None
5
2011-03-15
2005-05-05
Anonymous
No

Hi,
When i try to set the modulo timer register (16 bytes) like that:
//////////////////////////
#include <mc68hc908jb8.h>
void main(void)
{
#define MODULO 46875
TMOD=MODULO;
}
//////////////////////////
command used to launch SDCC:
sdcc --code-loc 0x0040 --data-loc 0x0070 --xram-loc 0x0070 --stack-loc 0x013f -mhc08 --out-fmt-s19 blink-led-c.c
SDCC version:
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.4.0 (Mar 7 2005) (UNIX) on Debian distro.
the asm result given in the listing file is:
287 ; TMOD=MODULO;
288 ; genAssign
001B 6E 1B 0F 289 mov #0x1B,*(_TMOD + 1)
001E 6E B7 0E 290 mov #0xB7,*_TMOD

But, in the Motorola MC68HC908JB8 documentation, they say:
"Writing to the high byte (TMODH) inhibits the TOF bit and overflow interrupt until the low byte (TMODL) is written."

So, if i understood, the asm code should be:
mov #0xB7,*_TMOD
mov #0x1B,*(_TMOD + 1)

When i change the code for:
#include <mc68hc908jb8.h>
void main(void)
{
TMODH=0x7B;
TMODL=0x1B;
}
Then, it works perfectly.
Thank's for your help and for this great C compiler for microcontrolers.
I've just began playing with it and it's a pretty good C compiler for HC08.

Discussion

  • Maarten Brock

    Maarten Brock - 2011-03-15

    This is a problem for all targets with combined sfr's which need a special access order. SDCC has no option to set the access order and thus this workaround is required.

    I do not consider this a bug. It could be a feature request though.

     
  • Maarten Brock

    Maarten Brock - 2011-03-15
    • labels: 587905 -->
     

Log in to post a comment.