davekelly
Joined: 04 Oct 2006 Posts: 53 Location: Berkshire, England
|
Stack Underflow |
Posted: Thu Jul 16, 2009 5:44 am |
|
|
V4.093
I have recently completely reinstalled my Vista PC from scratch, and now having problems with compiling applications.
In the past few days I have created new projects for the 16F648A and the 18F2620. Both are having problems with debugging, whether I use a RealICE, ICD2 or MPLAB SIM.
The startup code in the memory appears to be completely wrong.
I compiled this simple test program:
Code: |
#include <18F2620.h>
#use delay (clock = 20 M)
#fuses HS, NOFCMEN, NOIESO, PUT, BROWNOUT_NOSL, NOWDT, MCLR, NOPBADEN, NOLPT1OSC, CCP2B3, NOSTVREN, NOLVP, NODEBUG
#int_timer1
void timer1Overflow()
{
output_toggle (PIN_A2);
}
void main ()
{
enable_interrupts (GLOBAL);
enable_interrupts (INT_TIMER1);
while (1)
{
output_toggle (PIN_A1);
}
}
|
When stepping through the disassembly or Program Memory, the code steps through until it reaches a RETFIE instruction, which causes the stack underflow.
When I look at the listing, the code appears correct. The first instruction is a GOTO, the address corresponds to the start of the main function. However the disassembly in the Program Memory is completely wrong:
CCS PCH C Compiler, Version 4.093, 44595 16-Jul-09 12:16
Filename: main.lst
ROM used: 200 bytes (0%)
Largest free fragment is 65332
RAM used: 24 (1%) at main() level
24 (1%) worst case
Stack: 1 worst case (0 in main + 1 for interrupts)
*
00000: GOTO 00A8
*
00008: MOVWF 05
0000A: MOVFF FD8,06
0000E: MOVFF FE0,07
00012: MOVLB 0
00014: MOVFF FE9,0D
00018: MOVFF FEA,08
0001C: MOVFF FE1,09
00020: MOVFF FE2,0A
00024: MOVFF FD9,0B
00028: MOVFF FDA,0C
0002C: MOVFF FF3,14
00030: MOVFF FF4,15
00034: MOVFF FFA,16
00038: MOVFF 00,0F
0003C: MOVFF 01,10
00040: MOVFF 02,11
00044: MOVFF 03,12
00048: MOVFF 04,13
0004C: BTFSS F9D.0
Line Address Opcode Disassembly
1 0000 0200 MULWF 0, ACCESS
2 0002 1E1C COMF 0x1c, F, ACCESS
3 0004 8000 BSF 0, 0, ACCESS
4 0006 0080
5 0008 C00F MOVFF 0xf, 0xf
6 000A E00F BZ 0x2a
7 000C 400F RRNCF 0xf, W, ACCESS
8 000E CFE0 MOVFF 0xfe0, 0x7
9 0010 F007 NOP
10 0012 0100 MOVLB 0
11 0014 CFE9 MOVFF 0xfe9, 0xd
12 0016 F00D NOP
13 0018 CFEA MOVFF 0xfea, 0x8
14 001A F008 NOP
15 001C CFE1 MOVFF 0xfe1, 0x9
16 001E F009 NOP
17 0020 CFE2 MOVFF 0xfe2, 0xa
18 0022 F00A NOP
19 0024 CFD9 MOVFF 0xfd9, 0xb
20 0026 F00B NOP
21 0028 CFDA MOVFF 0xfda, 0xc
22 002A F00C NOP
23 002C CFF3 MOVFF 0xff3, 0x14
I was using MPLAB 8.33. The code compiled fine on my colleagues XP installation with MPLAB 8.30, so I have downgraded my MPLAB to that version, but with the same issues.
I also tried an older 4.083 compiler, with the same problems.
Anybody wise as to what is going on?
Edit:
I have just noticed when scrolling to the bottom of the disassembly, that is is putting the fuses settings at location 0, as these correspond with the disassembly above
.................... output_toggle (PIN_A1);
000C4: BCF F92.1
000C6: BTG F89.1
.................... }
000C8: BRA 00C4
.................... }
000CA: SLEEP
Configuration Fuses:
Word 1: 0200 HS NOIESO NOFCMEN
Word 2: 1E1C NOWDT BORV21 PUT BROWNOUT_NOSL WDT32768
Word 3: 8000 CCP2B3 NOPBADEN NOLPT1OSC MCLR
Word 4: 0080 NOSTVREN NODEBUG NOLVP NOXINST
Word 5: C00F NOPROTECT NOCPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTC NOWRTB
Word 7: 400F NOEBTR NOEBTRB
|
|