gnupic: PIC18F47J53


Previous by date: 12 Aug 2013 16:59:22 -0000 Re: gputils 1.2.0 #985, Borut Ražem
Next by date: 12 Aug 2013 16:59:22 -0000 Re: PIC18F47J53, Bob Jacobsen
Previous in thread:
Next in thread: 12 Aug 2013 16:59:22 -0000 Re: PIC18F47J53, Bob Jacobsen

Subject: PIC18F47J53
From: Luis de Arquer ####@####.####
Date: 12 Aug 2013 16:59:22 -0000
Message-Id: <CAD_DGvm7mpREfkaLqCfDQev1xh_4pqXxoCguyKoQ-i+e+bfWng@mail.gmail.com>

Gents,

I am using sdcc + gputils on a home-made board, with a PIC18F47J53
(44-pin TQFP microcontroller, and I am coming accross a few issues.
The fact that there are more than one issue, makes me think that maybe
something electrical is wrong.

However, just in case someone has experienced this before, I am
posting the most obvious of the problems.

I have tried a simple program blinking an LED. It does work, if I use
the instructions

PORTB &= 0x08
PORTB |= 0x08

for toggling the LED (see asm translation below).
However if I use

PORTB ^= 0x08

which translates to a BTG (bit toggle) instruction, it won't blink at
all -it will light the LED up though, but no blinking can be seen even
with the oscilloscope.

It looks to me that the C -> asm compilation is OK.

I know it sounds a bit ridiculous, and I think the chances are 50/50
that I am either making a very obvious error on the software side, or
there is some electronic issue on the board. However, after hours
messing around I couldn't find an explanation. Maybe the BTG
instruction is not available in the j-series, or coded in a different
way?

Below is the and/or-version asm code (the one that works), the
BTG-version asm code, and the gpasm/gplink command line.

BTW, has anyone succesfully used this microcontroller with gputils before?

Regards,

Luis de Arquer


*********************  AND/OR version (works OK!)
******************************

; I code from now on!
; ; Starting pCode block
S_test__main    code
_main:
;    .line    26; test.c    TRISB = ~0x08;
    MOVLW    0xf7
    MOVWF    _TRISB
;    .line    27; test.c    PORTB = PORTB | 0x08;
    BSF    _PORTB, 3
_00132_DS_:
;    .line    31; test.c    sleep_a_while(0x20);
    MOVLW    0x20
    MOVWF    POSTDEC1
    CALL    _sleep_a_while
    MOVF    POSTINC1, F
;    .line    33; test.c    PORTB &= ~0x08;
    MOVF    _PORTB, W
    MOVWF    r0x00
    MOVLW    0xf7
    ANDWF    r0x00, W
    MOVWF    _PORTB
;    .line    35; test.c    sleep_a_while(0x20);
    MOVLW    0x20
    MOVWF    POSTDEC1
    CALL    _sleep_a_while
    MOVF    POSTINC1, F
;    .line    37; test.c    PORTB |= 0x08;
    BSF    _PORTB, 3
    BRA    _00132_DS_
    RETURN



********************* BTG version -not working :( ************************

; I code from now on!
; ; Starting pCode block
S_test__main    code
_main:
;    .line    26; test.c    TRISB = ~0x08;
    MOVLW    0xf7
    MOVWF    _TRISB
;    .line    27; test.c    PORTB = PORTB | 0x08;
    BSF    _PORTB, 3
_00132_DS_:
;    .line    31; test.c    sleep_a_while(0x20);
    MOVLW    0x20
    MOVWF    POSTDEC1
    CALL    _sleep_a_while
    MOVF    POSTINC1, F
;    .line    33; test.c    PORTB ^= 0x08;
    BTG    _PORTB, 3
;    .line    35; test.c    sleep_a_while(0x20);
    MOVLW    0x20
    MOVWF    POSTDEC1
    CALL    _sleep_a_while
    MOVF    POSTINC1, F
;    .line    37; test.c    PORTB ^= 0x08;
    BTG    _PORTB, 3
    BRA    _00132_DS_
    RETURN



********************* Command line       ******************************

+ /usr/local/bin/gpasm -DSTACK_MODEL_SMALL -D__STACK_MODEL_SMALL -o
test.o -c test.asm
+ /usr/local/bin/gplink -I/usr/local/bin/../share/sdcc/lib/pic16
-I/usr/local/share/sdcc/lib/pic16
-I/usr/local/bin/../share/sdcc/non-free/lib/pic16
-I/usr/local/share/sdcc/non-free/lib/pic16   -w -r -o test test.o
crt0.o libdev18f47j53.lib libsdcc.lib libc18f.lib
message: using default linker script
"/usr/local/share/gputils/lkr/18f47j53_g.lkr"

Previous by date: 12 Aug 2013 16:59:22 -0000 Re: gputils 1.2.0 #985, Borut Ražem
Next by date: 12 Aug 2013 16:59:22 -0000 Re: PIC18F47J53, Bob Jacobsen
Previous in thread:
Next in thread: 12 Aug 2013 16:59:22 -0000 Re: PIC18F47J53, Bob Jacobsen


Powered by ezmlm-browse 0.20.