Hello,
I am trying software I2C routines in SDCC for PIC16F676. Currently with no success. So I played with bit-bang output and found some interesting feature (honestly, I do not know if it is a bug or feature).
Tha main problem is that when I set TRISA0 = 1; RA0 = 0; TRISA0 = 0 -> there is "1" on output - no "0". With sequence of TRISA0 = 0; RA0 = 0; I have "0" on RA0 as expected. So I played with pins.
I attached the excerpt from .LST file - just final while(1){} loop. And what am I doing inside ? "icnt" is local unsigned char variable.
On RA5 is a test LED which is OK. I am trying to set RA0 to "0" just first 10 times. But when I test icnt value I miss the banksel. So, effectively, instead of RA0 I set TRISA0 again. The result is that I don't see any blinking on RA0.
Can somebody skilled chack the code - if there is any problem ?
Thank you,
Vaclav
; .line 129; "main.c" while (1) {
00004b 01bc clrf 0x3c CLRF r0x1007
_00135_DS_
; .line 130; "main.c" RA5 = 0;
00004c 1283 bcf 0x3, 0x5 BANKSEL _PORTA_bits
00004d 1285 bcf 0x5, 0x5 BCF _PORTA_bits,5
; .line 131; "main.c" TRISA0 = 0;
00004e 1683 bsf 0x3, 0x5 BANKSEL _TRISA_bits
00004f 1005 bcf 0x5, 0 BCF _TRISA_bits,0
;unsigned compare: left < lit(0xA=10), size=1
; .line 132; "main.c" if (icnt < 10) {
000050 300a movlw 0xa MOVLW 0x0a
; .line 133; "main.c" RA0 = 0;
000051 023c subwf 0x3c, w SUBWF r0x1007,W
; .line 135; "main.c" gTimer = 3;
000052 1c03 btfss 0x3, 0 BTFSS STATUS,0
000053 1005 bcf 0x5, 0 BCF _PORTA_bits,0
000054 3003 movlw 0x3 MOVLW 0x03
000055 00c2 movwf 0x42 MOVWF _gTimer
_00126_DS_
; .line 136; "main.c" while ( gTimer) ;
000056 3000 movlw 0 MOVLW 0x00
000057 0442 iorwf 0x42, w IORWF _gTimer,W
000058 1d03 btfss 0x3, 0x2 BTFSS STATUS,2
000059 2856 goto 0x56 GOTO _00126_DS_
; .line 138; "main.c" RA5 = 1;
00005a 1283 bcf 0x3, 0x5 BANKSEL _PORTA_bits
00005b 1685 bsf 0x5, 0x5 BSF _PORTA_bits,5
; .line 139; "main.c" TRISA0 = 1;
00005c 1683 bsf 0x3, 0x5 BANKSEL _TRISA_bits
00005d 1405 bsf 0x5, 0 BSF _TRISA_bits,0
; .line 140; "main.c" gTimer = 3;
00005e 3003 movlw 0x3 MOVLW 0x03
00005f 00c2 movwf 0x42 MOVWF _gTimer
_00129_DS_
; .line 141; "main.c" while ( gTimer) ;
000060 3000 movlw 0 MOVLW 0x00
000061 0442 iorwf 0x42, w IORWF _gTimer,W
000062 1d03 btfss 0x3, 0x2 BTFSS STATUS,2
000063 2860 goto 0x60 GOTO _00129_DS_
;unsigned compare: left < lit(0x14=20), size=1
; .line 143; "main.c" if (icnt < 20) {
000064 3014 movlw 0x14 MOVLW 0x14
000065 023c subwf 0x3c, w SUBWF r0x1007,W
000066 1803 btfsc 0x3, 0 BTFSC STATUS,0
000067 284c goto 0x4c GOTO _00135_DS_
;genSkipc:3083: created from rifx:0p2260a4
; .line 144; "main.c" icnt++;
000068 0abc incf 0x3c, f INCF r0x1007,F
000069 284c goto 0x4c GOTO _00135_DS_
|