|
|
View previous topic :: View next topic |
Author |
Message |
object01
Joined: 13 May 2004 Posts: 90 Location: Nashville, TN
|
Instruction 0x0000 jumps to wrong address |
Posted: Wed May 11, 2005 12:49 pm |
|
|
When I debug the following program (PIC-C v3.223, ICD FW v1.39), and reset while looking at the listing, then step, I'm observing that the first instruction, GOTO 0068, does not actually go to 0068. Instead, it jumps to 002A. The program does not produce "HELLO WORLD" on the debugger.
Source:
Code: | #include <18F4620.h>
#device adc=8
#fuses NOWDT,WDT128,INTRC_IO, NOPROTECT, NOIESO, NOBROWNOUT, BORV21, NOPUT, NOCPD, NOSTVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, NOFCMEN, NOXINST, NOPBADEN, LPT1OSC, NOMCLR
#use delay(clock=8000000)
#use rs232(xmit=PIN_B5, rcv=PIN_B5, stream=DEBUGGER)
void main() {
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
printf("HELLO WORLD");
} |
List:
Code: | CCS PCH C Compiler, Version 3.223, 25633 11-May-05 13:45
Filename: C:\Documents and Settings\jas.MICRONOVATECH\Desktop\Experiments\4620 fprintf\main.LST
ROM used: 228 bytes (0%)
Largest free fragment is 64476
RAM used: 6 (0%) at main() level
7 (0%) worst case
Stack: 1 locations
*
0000: GOTO 0068
.................... #include <18F4620.h>
.................... //////// Standard Header file for the PIC18F4620 device ////////////////
.................... #device PIC18F4620
.................... #list
....................
.................... #device adc=8
.................... #fuses NOWDT,WDT128,INTRC_IO, NOPROTECT, NOIESO, NOBROWNOUT, BORV21, NOPUT, NOCPD, NOSTVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, NOFCMEN, NOXINST, NOPBADEN, LPT1OSC, NOMCLR
.................... #use delay(clock=8000000)
....................
.................... #use rs232(xmit=PIN_B5, rcv=PIN_B5, stream=DEBUGGER)
0020: BCF F93.5
0022: BCF F8A.5
0024: MOVLW 08
0026: MOVWF 01
0028: NOP
002A: NOP
002C: NOP
002E: BSF 01.7
0030: BRA 0050
0032: BCF 01.7
0034: RRCF 07,F
0036: BTFSC FD8.0
0038: BSF F8A.5
003A: BTFSS FD8.0
003C: BCF F8A.5
003E: BSF 01.6
0040: BRA 0050
0042: BCF 01.6
0044: DECFSZ 01,F
0046: BRA 0034
0048: NOP
004A: NOP
004C: NOP
004E: BSF F8A.5
0050: MOVLW 3E
0052: MOVWF FE9
0054: DECFSZ FE9,F
0056: BRA 0054
0058: NOP
005A: NOP
005C: BTFSC 01.7
005E: BRA 0032
0060: BTFSC 01.6
0062: BRA 0042
0064: GOTO 00DC (RETURN)
....................
.................... void main() {
....................
0068: CLRF FF8
006A: BCF FD0.7
006C: CLRF FEA
006E: CLRF FE9
0070: MOVF FC1,W
0072: ANDLW C0
0074: IORLW 0F
0076: MOVWF FC1
0078: MOVLW 07
007A: MOVWF FB4
007C: MOVF FB4,W
007E: BCF FA1.6
0080: MOVLW 70
0082: MOVWF FD3
0084: BCF F93.5
0086: BSF F8A.5
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
0088: MOVF FC1,W
008A: ANDLW C0
008C: IORLW 0F
008E: MOVWF FC1
.................... setup_adc(ADC_OFF|ADC_TAD_MUL_0);
0090: BCF FC2.0
.................... setup_psp(PSP_DISABLED);
0092: BCF F96.4
.................... setup_spi(FALSE);
0094: BCF FC6.5
0096: BCF F94.5
0098: BSF F94.4
009A: BCF F94.3
009C: MOVLW 00
009E: MOVWF FC6
00A0: MOVWF FC7
.................... setup_wdt(WDT_OFF);
00A2: BCF FD1.0
.................... setup_timer_0(RTCC_INTERNAL);
00A4: MOVLW 80
00A6: MOVWF FD5
.................... setup_timer_1(T1_DISABLED);
00A8: CLRF FCD
.................... setup_timer_2(T2_DISABLED,0,1);
00AA: MOVLW 00
00AC: MOVWF FCA
00AE: MOVLW 00
00B0: MOVWF FCB
.................... setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
00B2: MOVF FB1,W
00B4: ANDLW 48
00B6: MOVWF FB1
.................... setup_comparator(NC_NC_NC_NC);
00B8: MOVLW 07
00BA: MOVWF FB4
00BC: MOVF F92,W
00BE: MOVLW 06
00C0: MOVWF 00
00C2: DECFSZ 00,F
00C4: BRA 00C2
00C6: NOP
00C8: MOVF FB4,W
00CA: BCF FA1.6
.................... setup_vref(FALSE);
00CC: CLRF FB5
....................
.................... printf("HELLO WORLD");
00CE: CLRF 06
00D0: MOVF 06,W
00D2: RCALL 0004
00D4: INCF 06,F
00D6: MOVWF 00
00D8: MOVWF 07
00DA: BRA 0020
00DC: MOVLW 0B
00DE: SUBWF 06,W
00E0: BNZ 00D0
.................... }
....................
00E2: BRA 00E2
Configuration Fuses:
Word 1: 0800 NOIESO INTRC_IO NOFCMEN RESERVED
Word 2: 0E19 NOBROWNOUT WDT128 NOWDT BORV21 NOPUT
Word 3: 0500 CCP2C1 NOPBADEN LPT1OSC NOMCLR
Word 4: 0001 STVREN DEBUG NOLVP NOXINST RESERVED
Word 5: C00F NOPROTECT NOCPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTC NOWRTB
Word 7: 400F NOEBTR NOEBTRB |
|
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed May 11, 2005 4:00 pm |
|
|
1) The first goto should point to the main() starting.
2) If you are using the ICD, your code don�t shows that. It doesn�t have the #ICD=TRUE directive.
3) Ovbiously you have got this code from the project wizard, assuming you are just starting,
what is the reason to use this code:
#use rs232(xmit=PIN_B5, rcv=PIN_B5, stream=DEBUGGER)
instead of the simplest form until you get it running,
#use rs232(xmit=PIN_B5)
If you had defined only one Comm port, do not use STREAM at this step. Once you get
this minimal configuration running properly, add the other features.
Best wishes,
Humberto |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed May 11, 2005 4:10 pm |
|
|
1) The first goto should point to the main() starting.
2) If you are using the ICD, your code don�t shows that. It doesn�t have the #ICD=TRUE directive.
3) Ovbiously you have got this code from the project wizard, assuming you are just starting,
what is the reason to use this code:
#use rs232(xmit=PIN_B5, rcv=PIN_B5, stream=DEBUGGER)
instead of the simplest form until you get it running,
#use rs232(xmit=PIN_B5)
If you had defined only one Comm port, do not use STREAM at this step. Once you get
that this minimal configuration can run properly, add the other features.
Best wishes,
Humberto |
|
|
object01
Joined: 13 May 2004 Posts: 90 Location: Nashville, TN
|
|
Posted: Wed May 11, 2005 6:02 pm |
|
|
1) It does point to main starting, but the actual jump moves the program counter to 002A, not 0068.
2) The compiler implicitly adds the necessary ICD code when we enter debug mode. I generally keep #ICD=TRUE out of my programs to conserve program space in standalone mode.
3) No good reason, other than it's the way we do it in all our other programs.
--
Jeff S. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu May 12, 2005 7:37 am |
|
|
I dont have the 18F4620 but I tested with 18F452
PCW v3.221, ICD FW v1.29 Rev#163.
It works fine with and without the DEBUG mode.
The actual jump moves the program counter to 0040.
Code: |
*
0000: GOTO main
.................... #include <18F452.h>
.................... //////// Standard Header file for the PIC18F452 device ////////////////
.................... #device PIC18F452
.................... #list
....................
.................... #device ICD=TRUE
....................
.................... #fuses NOWDT,WDT128,XT, NOPROTECT, BROWNOUT, PUT, NOCPD, STVREN,\
.................... NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC
....................
.................... #use delay(clock=4000000)
.................... #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,enable=PIN_C5)
0020: BCF TRISC.5
0022: BSF LATC.5
0024: BTFSS PIR1.4
0026: BRA 0024
0028: MOVFF ??65535,TXREG
002C: NOP
002E: BCF TRISC.5
0030: BSF LATC.5
0032: BTFSS TXSTA.1
0034: BRA 0032
0036: BCF TRISC.5
0038: BCF LATC.5
003A: GOTO 009C (RETURN)
....................
.................... void main()
.................... {
003E: CLRF TBLPTRU
0040: BCF RCON.7
0042: CLRF FSR0H
0044: CLRF FSR0L
0046: BSF ADCON1.0
0048: BSF ADCON1.1
004A: BSF ADCON1.2
004C: BCF ADCON1.3
004E: BCF TRISC.5
0050: BCF LATC.5
0052: MOVLW 19
0054: MOVWF SPBRG
0056: MOVLW 26
0058: MOVWF TXSTA
005A: MOVLW 90
005C: MOVWF RCSTA
.................... setup_adc_ports(NO_ANALOGS);
005E: BSF ADCON1.0
0060: BSF ADCON1.1
0062: BSF ADCON1.2
0064: BCF ADCON1.3
.................... setup_psp(PSP_DISABLED);
0066: BCF TRISE.4
.................... setup_spi(FALSE);
0068: BCF SSPCON.5
006A: BCF TRISC.5
006C: BSF TRISC.4
006E: BCF TRISC.3
0070: MOVLW 00
0072: MOVWF SSPCON
0074: MOVWF SSPSTAT
.................... setup_wdt(WDT_OFF);
0076: BCF WDTCON.0
.................... setup_timer_0(RTCC_INTERNAL);
0078: MOVLW 80
007A: MOVWF T0CON
.................... setup_timer_1(T1_DISABLED);
007C: CLRF T1CON
.................... setup_timer_2(T2_DISABLED,0,1);
007E: MOVLW 00
0080: MOVWF T2CON
0082: MOVLW 00
0084: MOVWF PR2
.................... setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
0086: MOVF T3CON,W
0088: ANDLW 48
008A: MOVWF T3CON
....................
.................... printf("Hello word");
008C: CLRF @@06
008E: MOVF @@06,W
0090: RCALL 0004
0092: INCF @@06,F
0094: MOVWF @00
0096: MOVFF 00,??65535
009A: BRA 0020
009C: MOVLW 0A
009E: SUBWF @@06,W
00A0: BNZ 008E
.................... }
....................
00A2: BRA 00A2
Configuration Fuses:
Word 1: 2100 XT NOOSCSEN
Word 2: 0E0E BROWNOUT WDT128 NOWDT BORV20 PUT
Word 3: 0100 CCP2C1
Word 4: 0001 STVREN DEBUG NOLVP
Word 5: C00F NOPROTECT NOCPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTB NOWRTC
Word 7: 400F NOEBTR NOEBTRB
|
Humberto |
|
|
object01
Joined: 13 May 2004 Posts: 90 Location: Nashville, TN
|
|
Posted: Thu May 12, 2005 1:38 pm |
|
|
Talked with Kampurath at CCS and he found a workaround for the jump problem. He had me alter the ICD style for the 18Fx620 using the device editor, such that the forced fuses included NOSTVREN instead of STVREN. This solved the GOTO problem. He said this fix would be included in the next release (current release is 3.224).
However, I still can't get printf output to appear in the debug monitor, despite seeing the ASCII on the scope.
--
Jeff S. |
|
|
Masaya Guest
|
Jump to 0x002A on 18F2620 |
Posted: Fri May 13, 2005 7:41 am |
|
|
Thank you for good information. After I also had used 18F2620, it encountered the same problem
(jump to 0x002a). |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|