|
|
View previous topic :: View next topic |
Author |
Message |
Andreas
Joined: 25 Oct 2004 Posts: 136
|
Compiler Fails with PICKit3 !!!! |
Posted: Sun Jan 05, 2014 5:00 am |
|
|
Hello Friends !
I am running now the second time in a very fancy Problem and now I am able to break it down to only a few lines of code.
What is the Problem ??
I am running a simple test program for LED Display Units which get their data through SPI. It worked allready very fine for some weeks and now I am trying to extend it.
Here is now the funny Thing, when adding a specific procedure or function.
Programming this will run perfect BUT using PICKit3 the Program runs once and then stops..... When hitting the HALT i can see that the Program Loops in the reserved ICD Area !!!!!!!!!!!!!!!!
And now Comes the really strange Thing, Debugging the same program with the ICD-U64 is perfect !!! No Stops no Loops !!!!!!!!
Additionally when I start the IDE and try to connect to the PICKIT3 I get this Error msg:
PK3Err0040: The target device is not ready for debugging.
Please check your configuration bit settings and program
the device before proceeding.
BUT !!!!!! When removing the specific Code Segment it is able to debug !!!!
Code: |
#include <16F886.h>
#device ICD=TRUE
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES PROTECT //Code protected from reads
#FUSES NOCPD //No EE protection
#FUSES BROWNOUT //Reset when brownout detected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG //Debug mode for use with ICD
#FUSES NOWRT //Program memory not write protected
#FUSES BORV40 //Brownout reset at 4.0V
#FUSES RESERVED //Used to set the reserved FUSE bits
#use delay(clock=8000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=Com1,errors)
#use SPI(DO=PIN_B1,CLK=PIN_B0, MODE=0,STREAM=SWSPI,BITS=8,NOINIT)
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
char dispData[38];
int8 out;
int8 count;
int16 cycle;
int8 bcount;
int16 cyclepos;
int8 Bitpos;
int16 del;
int16 adc_Value;
int8 val1;
int8 val2;
void Single_LED()
{
bcount = 0;
out = 0;
output_high(PIN_C2);
for (cycle = 0; cycle < 288; cycle++)
{
del = 1;
bitpos = cycle % 8;
bcount = dispdata[bitpos];
cyclepos = cycle / 8;
output_low(PIN_C2);
for (count = 0; count < 36; count++)
{
if (count == cyclepos) out = bcount;
else out = 0xf0;
SPI_xfer(SWSPI,out);
}
output_high(PIN_C2);
delay_ms(del);
}
}
void Single_Line()
{
bcount = 0;
out = 0;
output_high(PIN_C2);
for (cycle = 0; cycle <16; cycle++)
{
del = 100;
bitpos = cycle % 8;
bcount = dispdata[bitpos];
val1 = 0xf0;
val2 = 0xf0;
if (cycle < 8) val1 = bcount;
if (cycle >7 ) val2 = bcount;
output_low(PIN_C2);
for (count = 0; count < 36; count++)
{
if (count < 18)
{
out = val2;
}
else
{
out = val1;
}
if (count > 17)
{
out = val2;
}
else
{
out = val1;
}
SPI_xfer(SWSPI,out);
}
output_high(PIN_C2);
delay_ms(del);
}
}
void Clear_LED(void)
{
output_low(PIN_C2);
for (count = 1; count < 37; count++)
{
SPI_xfer(SWSPI,0xf0);
}
output_high(PIN_C2);
}
#int_RDA
void RDA_isr(void)
{
}
#int_TIMER1
void TIMER1_isr(void)
{
set_timer1(0xF860); // 6000 20mS Timer
}
void main()
{
setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_2);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DIV_BY_1,0xFF,1);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
// enable_interrupts(INT_RDA);
enable_interrupts(INT_RTCC);
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_TIMER2);
setup_oscillator(OSC_8MHZ);
output_high(PIN_C3);
output_high(PIN_C5);
dispdata[0] = 0xf1;
dispdata[1] = 0xf2;
dispdata[2] = 0xf4;
dispdata[3] = 0xf8;
dispdata[4] = 0xe0;
dispdata[5] = 0xd0;
dispdata[6] = 0xb0;
dispdata[7] = 0x70;
while(true)
{
output_high(PIN_B3);
delay_ms(100);
output_low(PIN_B3);
delay_ms(100);
Clear_LED();
Single_LED();
delay_ms(100);
Single_Line();
}
} |
Now when I uncomment the line Single_Line(); then the program runs perfect is also able to be debugged !
When Using this line I can set the breakpoint to the line
output_high(PIN_B3);
Debugger stops there and now the funny Thing ::::: With pressing F7 the Cursor moves from line to line WITHOUT executing anything !!!!
Do You Specialists have any idea whats going wrong in here ??
Please be aware the same code runs out of CCS IDE without Problems !!
Any help is very very appreciated !!
best regards out of Vienna
Andreas |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9215 Location: Greensville,Ontario
|
|
Posted: Sun Jan 05, 2014 6:42 am |
|
|
comment: I see this...
#FUSES NODEBUG //Debug mode for use with ICD
...
yet you say you're using 'debug'( assuming MPLAB ). So there is a conflict.
While I've never used 'debug' to test code( I prefer 'real world' testing), I do know that in MPLAB the code 'compiled' using 'debug' is NOT the same as 'release' in the 'Build Configuration' menu.
Also in MPLAB, you can select an option to have either MPLAB or the compiled code configure the 'fuses'.
hth
jay |
|
|
Andreas
Joined: 25 Oct 2004 Posts: 136
|
|
Posted: Mon Jan 06, 2014 3:09 am |
|
|
Hello temtronic
Thanks for looking at my post.
Some additions now:
1. The NODEBUG I removed because some error message told me so.
2. My REAL Problem is, that having everything set the same it works with a code Segment commented and doesn't work with this Segment active !!!!!!!
3. The same code compiled with CCS IDE wrongs in either case !!!!!
How can I send You sample lst files ?
I have now 2 files one which is running with PICKit3 one is not !!
best regards
Andreas |
|
|
Andreas
Joined: 25 Oct 2004 Posts: 136
|
Again |
Posted: Mon Jan 06, 2014 3:13 am |
|
|
Here are two lst Files one is Debugging one not, please tell me the difference !
Working :
Code: |
CCS PCM C Compiler, Version 5.012, xxxx 06-Jan-14 09:55
Filename: C:\Servo_Regler_x\StaticDisplayText.lst
ROM used: 382 words (5%)
Largest free fragment is 2048
RAM used: 66 (18%) at main() level
71 (20%) worst case
Stack used: 3 locations (2 in main + 1 for interrupts)
Stack size: 7
*
0000: NOP
0001: MOVLW 00
0002: MOVWF 0A
0003: GOTO 0F3
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 0A,W
0009: MOVWF 20
000A: CLRF 0A
000B: MOVF 04,W
000C: MOVWF 22
000D: MOVF 77,W
000E: MOVWF 23
000F: MOVF 78,W
0010: MOVWF 24
0011: MOVF 79,W
0012: MOVWF 25
0013: MOVF 7A,W
0014: MOVWF 26
0015: BCF 03.7
0016: BCF 03.5
0017: MOVLW 8C
0018: MOVWF 04
0019: BTFSS 00.5
001A: GOTO 01D
001B: BTFSC 0C.5
001C: GOTO 034
001D: MOVLW 8C
001E: MOVWF 04
001F: BTFSS 00.0
0020: GOTO 023
0021: BTFSC 0C.0
0022: GOTO 037
0023: MOVF 22,W
0024: MOVWF 04
0025: MOVF 23,W
0026: MOVWF 77
0027: MOVF 24,W
0028: MOVWF 78
0029: MOVF 25,W
002A: MOVWF 79
002B: MOVF 26,W
002C: MOVWF 7A
002D: MOVF 20,W
002E: MOVWF 0A
002F: SWAPF 21,W
0030: MOVWF 03
0031: SWAPF 7F,F
0032: SWAPF 7F,W
0033: RETFIE
0034: BCF 0A.3
0035: BCF 0A.4
0036: GOTO 03A
0037: BCF 0A.3
0038: BCF 0A.4
0039: GOTO 03E
.................... #include <16F886.h>
.................... ///////////// Standard Header file for the PIC16F886 device ////////////////
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996, 2013 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... #device PIC16F886
....................
.................... #list
....................
.................... #device ICD=TRUE
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES INTRC //Internal RC Osc, no CLKOUT
.................... #FUSES PUT //Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES PROTECT //Code protected from reads
.................... #FUSES NOCPD //No EE protection
.................... #FUSES BROWNOUT //Reset when brownout detected
.................... #FUSES IESO //Internal External Switch Over mode enabled
.................... #FUSES FCMEN //Fail-safe clock monitor enabled
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NODEBUG //Debug mode for use with ICD
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES BORV40 //Brownout reset at 4.0V
.................... #FUSES RESERVED //Used to set the reserved FUSE bits
....................
....................
.................... #use delay(clock=8000000)
*
0047: MOVLW 5E
0048: MOVWF 04
0049: BCF 03.7
004A: MOVF 00,W
004B: BTFSC 03.2
004C: GOTO 05A
004D: MOVLW 02
004E: MOVWF 78
004F: CLRF 77
0050: DECFSZ 77,F
0051: GOTO 050
0052: DECFSZ 78,F
0053: GOTO 04F
0054: MOVLW 97
0055: MOVWF 77
0056: DECFSZ 77,F
0057: GOTO 056
0058: DECFSZ 00,F
0059: GOTO 04D
005A: RETURN
.................... #use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=Com1,errors)
.................... #use SPI(DO=PIN_B1,CLK=PIN_B0, MODE=0,STREAM=SWSPI,BITS=8,NOINIT)
005B: MOVF 5E,W
005C: SUBLW 08
005D: BTFSC 03.2
005E: GOTO 063
005F: MOVWF 5F
0060: RLF 5D,F
0061: DECFSZ 5F,F
0062: GOTO 060
0063: BSF 03.5
0064: BCF 06.1
0065: BCF 06.0
0066: BCF 03.5
0067: BCF 06.0
0068: MOVF 5E,W
0069: MOVWF 5F
006A: BTFSS 5D.7
006B: BCF 06.1
006C: BTFSC 5D.7
006D: BSF 06.1
006E: RLF 5D,F
006F: BSF 06.0
0070: GOTO 071
0071: BCF 06.0
0072: DECFSZ 5F,F
0073: GOTO 06A
0074: RETURN
....................
.................... #define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
.................... #define SPI_MODE_1 (SPI_L_TO_H)
.................... #define SPI_MODE_2 (SPI_H_TO_L)
.................... #define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
....................
....................
.................... char dispData[38];
.................... int8 out;
.................... int8 count;
.................... int16 cycle;
.................... int8 bcount;
.................... int16 cyclepos;
.................... int8 Bitpos;
.................... int16 del;
.................... int16 adc_Value;
.................... int8 val1;
.................... int8 val2;
....................
....................
.................... void Single_LED()
.................... {
.................... bcount = 0;
*
0091: CLRF 52
.................... out = 0;
0092: CLRF 4E
.................... output_high(PIN_C2);
0093: BCF 5C.2
0094: MOVF 5C,W
0095: BSF 03.5
0096: MOVWF 07
0097: BCF 03.5
0098: BSF 07.2
.................... for (cycle = 0; cycle < 288; cycle++)
0099: CLRF 51
009A: CLRF 50
009B: MOVF 51,W
009C: SUBLW 01
009D: BTFSS 03.0
009E: GOTO 0F0
009F: BTFSS 03.2
00A0: GOTO 0A5
00A1: MOVF 50,W
00A2: SUBLW 1F
00A3: BTFSS 03.0
00A4: GOTO 0F0
.................... {
.................... del = 1;
00A5: CLRF 57
00A6: MOVLW 01
00A7: MOVWF 56
.................... bitpos = cycle % 8;
00A8: MOVF 50,W
00A9: ANDLW 07
00AA: MOVWF 55
.................... bcount = dispdata[bitpos];
00AB: MOVLW 28
00AC: ADDWF 55,W
00AD: MOVWF 04
00AE: BCF 03.7
00AF: MOVF 00,W
00B0: MOVWF 52
.................... cyclepos = cycle / 8;
00B1: RRF 51,W
00B2: MOVWF 54
00B3: RRF 50,W
00B4: MOVWF 53
00B5: RRF 54,F
00B6: RRF 53,F
00B7: RRF 54,F
00B8: RRF 53,F
00B9: MOVLW 1F
00BA: ANDWF 54,F
....................
.................... output_low(PIN_C2);
00BB: BCF 5C.2
00BC: MOVF 5C,W
00BD: BSF 03.5
00BE: MOVWF 07
00BF: BCF 03.5
00C0: BCF 07.2
.................... for (count = 0; count < 36; count++)
00C1: CLRF 4F
00C2: MOVF 4F,W
00C3: SUBLW 23
00C4: BTFSS 03.0
00C5: GOTO 0D9
.................... {
.................... if (count == cyclepos) out = bcount;
00C6: MOVF 53,W
00C7: SUBWF 4F,W
00C8: BTFSS 03.2
00C9: GOTO 0D0
00CA: MOVF 54,F
00CB: BTFSS 03.2
00CC: GOTO 0D0
00CD: MOVF 52,W
00CE: MOVWF 4E
00CF: GOTO 0D2
.................... else out = 0xf0;
00D0: MOVLW F0
00D1: MOVWF 4E
.................... SPI_xfer(SWSPI,out);
00D2: MOVF 4E,W
00D3: MOVWF 5D
00D4: MOVLW 08
00D5: MOVWF 5E
00D6: CALL 05B
00D7: INCF 4F,F
00D8: GOTO 0C2
.................... }
.................... output_high(PIN_C2);
00D9: BCF 5C.2
00DA: MOVF 5C,W
00DB: BSF 03.5
00DC: MOVWF 07
00DD: BCF 03.5
00DE: BSF 07.2
.................... delay_ms(del);
00DF: MOVF 57,W
00E0: MOVWF 5D
00E1: INCF 5D,F
00E2: DECF 5D,F
00E3: BTFSC 03.2
00E4: GOTO 0E9
00E5: MOVLW FF
00E6: MOVWF 5E
00E7: CALL 047
00E8: GOTO 0E2
00E9: MOVF 56,W
00EA: MOVWF 5E
00EB: CALL 047
00EC: INCF 50,F
00ED: BTFSC 03.2
00EE: INCF 51,F
00EF: GOTO 09B
.................... }
00F0: BCF 0A.3
00F1: BCF 0A.4
00F2: GOTO 179 (RETURN)
.................... }
....................
.................... void Single_Line()
.................... {
.................... bcount = 0;
.................... out = 0;
.................... output_high(PIN_C2);
.................... for (cycle = 0; cycle <16; cycle++)
.................... {
.................... del = 100;
....................
.................... bitpos = cycle % 8;
.................... bcount = dispdata[bitpos];
.................... val1 = 0xf0;
.................... val2 = 0xf0;
.................... if (cycle < 8) val1 = bcount;
.................... if (cycle >7 ) val2 = bcount;
....................
.................... output_low(PIN_C2);
.................... for (count = 0; count < 36; count++)
.................... {
.................... if (count < 18)
.................... {
.................... out = val2;
.................... }
.................... else
.................... {
.................... out = val1;
.................... }
.................... if (count > 17)
.................... {
.................... out = val2;
.................... }
.................... else
.................... {
.................... out = val1;
.................... }
.................... SPI_xfer(SWSPI,out);
.................... }
.................... output_high(PIN_C2);
.................... delay_ms(del);
.................... }
.................... }
....................
.................... void Clear_LED(void)
.................... {
.................... output_low(PIN_C2);
*
0075: BCF 5C.2
0076: MOVF 5C,W
0077: BSF 03.5
0078: MOVWF 07
0079: BCF 03.5
007A: BCF 07.2
.................... for (count = 1; count < 37; count++)
007B: MOVLW 01
007C: MOVWF 4F
007D: MOVF 4F,W
007E: SUBLW 24
007F: BTFSS 03.0
0080: GOTO 088
.................... {
.................... SPI_xfer(SWSPI,0xf0);
0081: MOVLW F0
0082: MOVWF 5D
0083: MOVLW 08
0084: MOVWF 5E
0085: CALL 05B
0086: INCF 4F,F
0087: GOTO 07D
.................... }
.................... output_high(PIN_C2);
0088: BCF 5C.2
0089: MOVF 5C,W
008A: BSF 03.5
008B: MOVWF 07
008C: BCF 03.5
008D: BSF 07.2
008E: BCF 0A.3
008F: BCF 0A.4
0090: GOTO 178 (RETURN)
.................... }
....................
.................... #int_RDA
.................... void RDA_isr(void)
.................... {
....................
.................... }
....................
*
003A: BCF 0C.5
003B: BCF 0A.3
003C: BCF 0A.4
003D: GOTO 023
.................... #int_TIMER1
.................... void TIMER1_isr(void)
.................... {
.................... set_timer1(0xF860); // 6000 20mS Timer
003E: CLRF 0E
003F: MOVLW F8
0040: MOVWF 0F
0041: MOVLW 60
0042: MOVWF 0E
0043: BCF 0C.0
0044: BCF 0A.3
0045: BCF 0A.4
0046: GOTO 023
.................... }
....................
....................
.................... void main()
*
00F3: MOVF 03,W
00F4: ANDLW 1F
00F5: MOVWF 03
00F6: MOVLW 71
00F7: BSF 03.5
00F8: MOVWF 0F
00F9: MOVF 0F,W
00FA: BCF 03.5
00FB: CLRF 27
00FC: BSF 03.5
00FD: BSF 03.6
00FE: BCF 07.3
00FF: MOVLW 0C
0100: BCF 03.6
0101: MOVWF 19
0102: MOVLW A6
0103: MOVWF 18
0104: MOVLW 90
0105: BCF 03.5
0106: MOVWF 18
0107: BSF 03.5
0108: BCF 06.1
0109: BCF 06.0
010A: BCF 03.5
010B: BCF 06.0
010C: MOVLW FF
010D: MOVWF 5C
010E: BSF 03.5
010F: BSF 03.6
0110: MOVF 09,W
0111: ANDLW C0
0112: MOVWF 09
0113: BCF 03.6
0114: BCF 1F.4
0115: BCF 1F.5
0116: MOVLW 00
0117: BSF 03.6
0118: MOVWF 08
0119: BCF 03.5
011A: CLRF 07
011B: CLRF 08
011C: CLRF 09
011D: BCF 03.7
.................... {
.................... setup_adc_ports(sAN0);
011E: BSF 03.5
011F: MOVF 09,W
0120: ANDLW C0
0121: MOVWF 09
0122: BCF 03.6
0123: BCF 1F.4
0124: BCF 1F.5
0125: MOVLW 01
0126: BSF 03.6
0127: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_2);
0128: BCF 03.5
0129: BCF 03.6
012A: BCF 1F.6
012B: BCF 1F.7
012C: BSF 03.5
012D: BCF 1F.7
012E: BCF 03.5
012F: BSF 1F.0
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
0130: BSF 03.5
0131: MOVF 01,W
0132: ANDLW C0
0133: IORLW 07
0134: MOVWF 01
.................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
0135: MOVLW 05
0136: BCF 03.5
0137: MOVWF 10
.................... setup_timer_2(T2_DIV_BY_1,0xFF,1);
0138: MOVLW 00
0139: MOVWF 78
013A: IORLW 04
013B: MOVWF 12
013C: MOVLW FF
013D: BSF 03.5
013E: MOVWF 12
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
013F: BCF 03.5
0140: BSF 03.6
0141: CLRF 07
0142: CLRF 08
0143: CLRF 09
.................... // enable_interrupts(INT_RDA);
.................... enable_interrupts(INT_RTCC);
0144: BCF 03.6
0145: BSF 0B.5
.................... enable_interrupts(INT_TIMER1);
0146: BSF 03.5
0147: BSF 0C.0
.................... enable_interrupts(INT_TIMER2);
0148: BSF 0C.1
.................... setup_oscillator(OSC_8MHZ);
0149: MOVLW 71
014A: MOVWF 0F
014B: MOVF 0F,W
....................
.................... output_high(PIN_C3);
014C: BCF 03.5
014D: BCF 5C.3
014E: MOVF 5C,W
014F: BSF 03.5
0150: MOVWF 07
0151: BCF 03.5
0152: BSF 07.3
.................... output_high(PIN_C5);
0153: BCF 5C.5
0154: MOVF 5C,W
0155: BSF 03.5
0156: MOVWF 07
0157: BCF 03.5
0158: BSF 07.5
....................
.................... dispdata[0] = 0xf1;
0159: MOVLW F1
015A: MOVWF 28
.................... dispdata[1] = 0xf2;
015B: MOVLW F2
015C: MOVWF 29
.................... dispdata[2] = 0xf4;
015D: MOVLW F4
015E: MOVWF 2A
.................... dispdata[3] = 0xf8;
015F: MOVLW F8
0160: MOVWF 2B
.................... dispdata[4] = 0xe0;
0161: MOVLW E0
0162: MOVWF 2C
.................... dispdata[5] = 0xd0;
0163: MOVLW D0
0164: MOVWF 2D
.................... dispdata[6] = 0xb0;
0165: MOVLW B0
0166: MOVWF 2E
.................... dispdata[7] = 0x70;
0167: MOVLW 70
0168: MOVWF 2F
....................
....................
.................... while(true)
.................... {
.................... output_high(PIN_B3);
0169: BSF 03.5
016A: BCF 06.3
016B: BCF 03.5
016C: BSF 06.3
.................... delay_ms(100);
016D: MOVLW 64
016E: MOVWF 5E
016F: CALL 047
.................... output_low(PIN_B3);
0170: BSF 03.5
0171: BCF 06.3
0172: BCF 03.5
0173: BCF 06.3
.................... delay_ms(100);
0174: MOVLW 64
0175: MOVWF 5E
0176: CALL 047
.................... Clear_LED();
0177: GOTO 075
.................... Single_LED();
0178: GOTO 091
.................... delay_ms(100);
0179: MOVLW 64
017A: MOVWF 5E
017B: CALL 047
017C: GOTO 169
.................... //Single_Line();
....................
.................... }
.................... }
017D: GOTO 17D
Configuration Fuses:
Word 1: 0CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP DEBUG
Word 2: 3FFF BORV40 NOWRT
Some fuses have been forced to be compatible with the ICD debugger.
|
NOT working:
Code: |
CCS PCM C Compiler, Version 5.012, xxxx 06-Jan-14 09:56
Filename: C:\Servo_Regler_x\StaticDisplayText.lst
ROM used: 495 words (6%)
Largest free fragment is 2048
RAM used: 66 (18%) at main() level
71 (20%) worst case
Stack used: 3 locations (2 in main + 1 for interrupts)
Stack size: 7
*
0000: NOP
0001: MOVLW 01
0002: MOVWF 0A
0003: GOTO 163
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 0A,W
0009: MOVWF 20
000A: CLRF 0A
000B: MOVF 04,W
000C: MOVWF 22
000D: MOVF 77,W
000E: MOVWF 23
000F: MOVF 78,W
0010: MOVWF 24
0011: MOVF 79,W
0012: MOVWF 25
0013: MOVF 7A,W
0014: MOVWF 26
0015: BCF 03.7
0016: BCF 03.5
0017: MOVLW 8C
0018: MOVWF 04
0019: BTFSS 00.5
001A: GOTO 01D
001B: BTFSC 0C.5
001C: GOTO 034
001D: MOVLW 8C
001E: MOVWF 04
001F: BTFSS 00.0
0020: GOTO 023
0021: BTFSC 0C.0
0022: GOTO 037
0023: MOVF 22,W
0024: MOVWF 04
0025: MOVF 23,W
0026: MOVWF 77
0027: MOVF 24,W
0028: MOVWF 78
0029: MOVF 25,W
002A: MOVWF 79
002B: MOVF 26,W
002C: MOVWF 7A
002D: MOVF 20,W
002E: MOVWF 0A
002F: SWAPF 21,W
0030: MOVWF 03
0031: SWAPF 7F,F
0032: SWAPF 7F,W
0033: RETFIE
0034: BCF 0A.3
0035: BCF 0A.4
0036: GOTO 03A
0037: BCF 0A.3
0038: BCF 0A.4
0039: GOTO 03E
.................... #include <16F886.h>
.................... ///////////// Standard Header file for the PIC16F886 device ////////////////
.................... ///////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996, 2013 Custom Computer Services ////
.................... //// This source code may only be used by licensed users of the CCS C ////
.................... //// compiler. This source code may only be distributed to other ////
.................... //// licensed users of the CCS C compiler. No other use, reproduction ////
.................... //// or distribution is permitted without written permission. ////
.................... //// Derivative programs created using this software in object code ////
.................... //// form are not restricted in any way. ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... #device PIC16F886
....................
.................... #list
....................
.................... #device ICD=TRUE
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES INTRC //Internal RC Osc, no CLKOUT
.................... #FUSES PUT //Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES PROTECT //Code protected from reads
.................... #FUSES NOCPD //No EE protection
.................... #FUSES BROWNOUT //Reset when brownout detected
.................... #FUSES IESO //Internal External Switch Over mode enabled
.................... #FUSES FCMEN //Fail-safe clock monitor enabled
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NODEBUG //Debug mode for use with ICD
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES BORV40 //Brownout reset at 4.0V
.................... #FUSES RESERVED //Used to set the reserved FUSE bits
....................
....................
.................... #use delay(clock=8000000)
*
0047: MOVLW 5E
0048: MOVWF 04
0049: BCF 03.7
004A: MOVF 00,W
004B: BTFSC 03.2
004C: GOTO 05A
004D: MOVLW 02
004E: MOVWF 78
004F: CLRF 77
0050: DECFSZ 77,F
0051: GOTO 050
0052: DECFSZ 78,F
0053: GOTO 04F
0054: MOVLW 97
0055: MOVWF 77
0056: DECFSZ 77,F
0057: GOTO 056
0058: DECFSZ 00,F
0059: GOTO 04D
005A: RETURN
.................... #use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=Com1,errors)
.................... #use SPI(DO=PIN_B1,CLK=PIN_B0, MODE=0,STREAM=SWSPI,BITS=8,NOINIT)
005B: MOVF 5E,W
005C: SUBLW 08
005D: BTFSC 03.2
005E: GOTO 063
005F: MOVWF 5F
0060: RLF 5D,F
0061: DECFSZ 5F,F
0062: GOTO 060
0063: BSF 03.5
0064: BCF 06.1
0065: BCF 06.0
0066: BCF 03.5
0067: BCF 06.0
0068: MOVF 5E,W
0069: MOVWF 5F
006A: BTFSS 5D.7
006B: BCF 06.1
006C: BTFSC 5D.7
006D: BSF 06.1
006E: RLF 5D,F
006F: BSF 06.0
0070: GOTO 071
0071: BCF 06.0
0072: DECFSZ 5F,F
0073: GOTO 06A
0074: RETURN
....................
.................... #define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
.................... #define SPI_MODE_1 (SPI_L_TO_H)
.................... #define SPI_MODE_2 (SPI_H_TO_L)
.................... #define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)
....................
....................
.................... char dispData[38];
.................... int8 out;
.................... int8 count;
.................... int16 cycle;
.................... int8 bcount;
.................... int16 cyclepos;
.................... int8 Bitpos;
.................... int16 del;
.................... int16 adc_Value;
.................... int8 val1;
.................... int8 val2;
....................
....................
.................... void Single_LED()
.................... {
.................... bcount = 0;
*
0091: CLRF 52
.................... out = 0;
0092: CLRF 4E
.................... output_high(PIN_C2);
0093: BCF 5C.2
0094: MOVF 5C,W
0095: BSF 03.5
0096: MOVWF 07
0097: BCF 03.5
0098: BSF 07.2
.................... for (cycle = 0; cycle < 288; cycle++)
0099: CLRF 51
009A: CLRF 50
009B: MOVF 51,W
009C: SUBLW 01
009D: BTFSS 03.0
009E: GOTO 0F0
009F: BTFSS 03.2
00A0: GOTO 0A5
00A1: MOVF 50,W
00A2: SUBLW 1F
00A3: BTFSS 03.0
00A4: GOTO 0F0
.................... {
.................... del = 1;
00A5: CLRF 57
00A6: MOVLW 01
00A7: MOVWF 56
.................... bitpos = cycle % 8;
00A8: MOVF 50,W
00A9: ANDLW 07
00AA: MOVWF 55
.................... bcount = dispdata[bitpos];
00AB: MOVLW 28
00AC: ADDWF 55,W
00AD: MOVWF 04
00AE: BCF 03.7
00AF: MOVF 00,W
00B0: MOVWF 52
.................... cyclepos = cycle / 8;
00B1: RRF 51,W
00B2: MOVWF 54
00B3: RRF 50,W
00B4: MOVWF 53
00B5: RRF 54,F
00B6: RRF 53,F
00B7: RRF 54,F
00B8: RRF 53,F
00B9: MOVLW 1F
00BA: ANDWF 54,F
....................
.................... output_low(PIN_C2);
00BB: BCF 5C.2
00BC: MOVF 5C,W
00BD: BSF 03.5
00BE: MOVWF 07
00BF: BCF 03.5
00C0: BCF 07.2
.................... for (count = 0; count < 36; count++)
00C1: CLRF 4F
00C2: MOVF 4F,W
00C3: SUBLW 23
00C4: BTFSS 03.0
00C5: GOTO 0D9
.................... {
.................... if (count == cyclepos) out = bcount;
00C6: MOVF 53,W
00C7: SUBWF 4F,W
00C8: BTFSS 03.2
00C9: GOTO 0D0
00CA: MOVF 54,F
00CB: BTFSS 03.2
00CC: GOTO 0D0
00CD: MOVF 52,W
00CE: MOVWF 4E
00CF: GOTO 0D2
.................... else out = 0xf0;
00D0: MOVLW F0
00D1: MOVWF 4E
.................... SPI_xfer(SWSPI,out);
00D2: MOVF 4E,W
00D3: MOVWF 5D
00D4: MOVLW 08
00D5: MOVWF 5E
00D6: CALL 05B
00D7: INCF 4F,F
00D8: GOTO 0C2
.................... }
.................... output_high(PIN_C2);
00D9: BCF 5C.2
00DA: MOVF 5C,W
00DB: BSF 03.5
00DC: MOVWF 07
00DD: BCF 03.5
00DE: BSF 07.2
.................... delay_ms(del);
00DF: MOVF 57,W
00E0: MOVWF 5D
00E1: INCF 5D,F
00E2: DECF 5D,F
00E3: BTFSC 03.2
00E4: GOTO 0E9
00E5: MOVLW FF
00E6: MOVWF 5E
00E7: CALL 047
00E8: GOTO 0E2
00E9: MOVF 56,W
00EA: MOVWF 5E
00EB: CALL 047
00EC: INCF 50,F
00ED: BTFSC 03.2
00EE: INCF 51,F
00EF: GOTO 09B
.................... }
00F0: BCF 0A.3
00F1: BCF 0A.4
00F2: GOTO 1E9 (RETURN)
.................... }
....................
.................... void Single_Line()
.................... {
.................... bcount = 0;
00F3: CLRF 52
.................... out = 0;
00F4: CLRF 4E
.................... output_high(PIN_C2);
00F5: BCF 5C.2
00F6: MOVF 5C,W
00F7: BSF 03.5
00F8: MOVWF 07
00F9: BCF 03.5
00FA: BSF 07.2
.................... for (cycle = 0; cycle <16; cycle++)
00FB: CLRF 51
00FC: CLRF 50
00FD: MOVF 51,F
00FE: BTFSS 03.2
00FF: GOTO 160
0100: MOVF 50,W
0101: SUBLW 0F
0102: BTFSS 03.0
0103: GOTO 160
.................... {
.................... del = 100;
0104: CLRF 57
0105: MOVLW 64
0106: MOVWF 56
....................
.................... bitpos = cycle % 8;
0107: MOVF 50,W
0108: ANDLW 07
0109: MOVWF 55
.................... bcount = dispdata[bitpos];
010A: MOVLW 28
010B: ADDWF 55,W
010C: MOVWF 04
010D: BCF 03.7
010E: MOVF 00,W
010F: MOVWF 52
.................... val1 = 0xf0;
0110: MOVLW F0
0111: MOVWF 5A
.................... val2 = 0xf0;
0112: MOVWF 5B
.................... if (cycle < 8) val1 = bcount;
0113: MOVF 51,F
0114: BTFSS 03.2
0115: GOTO 11C
0116: MOVF 50,W
0117: SUBLW 07
0118: BTFSS 03.0
0119: GOTO 11C
011A: MOVF 52,W
011B: MOVWF 5A
.................... if (cycle >7 ) val2 = bcount;
011C: MOVF 51,F
011D: BTFSS 03.2
011E: GOTO 123
011F: MOVF 50,W
0120: SUBLW 07
0121: BTFSC 03.0
0122: GOTO 125
0123: MOVF 52,W
0124: MOVWF 5B
....................
.................... output_low(PIN_C2);
0125: BCF 5C.2
0126: MOVF 5C,W
0127: BSF 03.5
0128: MOVWF 07
0129: BCF 03.5
012A: BCF 07.2
.................... for (count = 0; count < 36; count++)
012B: CLRF 4F
012C: MOVF 4F,W
012D: SUBLW 23
012E: BTFSS 03.0
012F: GOTO 149
.................... {
.................... if (count < 18)
0130: MOVF 4F,W
0131: SUBLW 11
0132: BTFSS 03.0
0133: GOTO 137
.................... {
.................... out = val2;
0134: MOVF 5B,W
0135: MOVWF 4E
.................... }
0136: GOTO 139
.................... else
.................... {
.................... out = val1;
0137: MOVF 5A,W
0138: MOVWF 4E
.................... }
.................... if (count > 17)
0139: MOVF 4F,W
013A: SUBLW 11
013B: BTFSC 03.0
013C: GOTO 140
.................... {
.................... out = val2;
013D: MOVF 5B,W
013E: MOVWF 4E
.................... }
013F: GOTO 142
.................... else
.................... {
.................... out = val1;
0140: MOVF 5A,W
0141: MOVWF 4E
.................... }
.................... SPI_xfer(SWSPI,out);
0142: MOVF 4E,W
0143: MOVWF 5D
0144: MOVLW 08
0145: MOVWF 5E
0146: CALL 05B
0147: INCF 4F,F
0148: GOTO 12C
.................... }
.................... output_high(PIN_C2);
0149: BCF 5C.2
014A: MOVF 5C,W
014B: BSF 03.5
014C: MOVWF 07
014D: BCF 03.5
014E: BSF 07.2
.................... delay_ms(del);
014F: MOVF 57,W
0150: MOVWF 5D
0151: INCF 5D,F
0152: DECF 5D,F
0153: BTFSC 03.2
0154: GOTO 159
0155: MOVLW FF
0156: MOVWF 5E
0157: CALL 047
0158: GOTO 152
0159: MOVF 56,W
015A: MOVWF 5E
015B: CALL 047
015C: INCF 50,F
015D: BTFSC 03.2
015E: INCF 51,F
015F: GOTO 0FD
.................... }
0160: BCF 0A.3
0161: BCF 0A.4
0162: GOTO 1ED (RETURN)
.................... }
....................
.................... void Clear_LED(void)
.................... {
.................... output_low(PIN_C2);
*
0075: BCF 5C.2
0076: MOVF 5C,W
0077: BSF 03.5
0078: MOVWF 07
0079: BCF 03.5
007A: BCF 07.2
.................... for (count = 1; count < 37; count++)
007B: MOVLW 01
007C: MOVWF 4F
007D: MOVF 4F,W
007E: SUBLW 24
007F: BTFSS 03.0
0080: GOTO 088
.................... {
.................... SPI_xfer(SWSPI,0xf0);
0081: MOVLW F0
0082: MOVWF 5D
0083: MOVLW 08
0084: MOVWF 5E
0085: CALL 05B
0086: INCF 4F,F
0087: GOTO 07D
.................... }
.................... output_high(PIN_C2);
0088: BCF 5C.2
0089: MOVF 5C,W
008A: BSF 03.5
008B: MOVWF 07
008C: BCF 03.5
008D: BSF 07.2
008E: BCF 0A.3
008F: BCF 0A.4
0090: GOTO 1E8 (RETURN)
.................... }
....................
.................... #int_RDA
.................... void RDA_isr(void)
.................... {
....................
.................... }
....................
*
003A: BCF 0C.5
003B: BCF 0A.3
003C: BCF 0A.4
003D: GOTO 023
.................... #int_TIMER1
.................... void TIMER1_isr(void)
.................... {
.................... set_timer1(0xF860); // 6000 20mS Timer
003E: CLRF 0E
003F: MOVLW F8
0040: MOVWF 0F
0041: MOVLW 60
0042: MOVWF 0E
0043: BCF 0C.0
0044: BCF 0A.3
0045: BCF 0A.4
0046: GOTO 023
.................... }
....................
....................
.................... void main()
*
0163: MOVF 03,W
0164: ANDLW 1F
0165: MOVWF 03
0166: MOVLW 71
0167: BSF 03.5
0168: MOVWF 0F
0169: MOVF 0F,W
016A: BCF 03.5
016B: CLRF 27
016C: BSF 03.5
016D: BSF 03.6
016E: BCF 07.3
016F: MOVLW 0C
0170: BCF 03.6
0171: MOVWF 19
0172: MOVLW A6
0173: MOVWF 18
0174: MOVLW 90
0175: BCF 03.5
0176: MOVWF 18
0177: BSF 03.5
0178: BCF 06.1
0179: BCF 06.0
017A: BCF 03.5
017B: BCF 06.0
017C: MOVLW FF
017D: MOVWF 5C
017E: BSF 03.5
017F: BSF 03.6
0180: MOVF 09,W
0181: ANDLW C0
0182: MOVWF 09
0183: BCF 03.6
0184: BCF 1F.4
0185: BCF 1F.5
0186: MOVLW 00
0187: BSF 03.6
0188: MOVWF 08
0189: BCF 03.5
018A: CLRF 07
018B: CLRF 08
018C: CLRF 09
018D: BCF 03.7
.................... {
.................... setup_adc_ports(sAN0);
018E: BSF 03.5
018F: MOVF 09,W
0190: ANDLW C0
0191: MOVWF 09
0192: BCF 03.6
0193: BCF 1F.4
0194: BCF 1F.5
0195: MOVLW 01
0196: BSF 03.6
0197: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_2);
0198: BCF 03.5
0199: BCF 03.6
019A: BCF 1F.6
019B: BCF 1F.7
019C: BSF 03.5
019D: BCF 1F.7
019E: BCF 03.5
019F: BSF 1F.0
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
01A0: BSF 03.5
01A1: MOVF 01,W
01A2: ANDLW C0
01A3: IORLW 07
01A4: MOVWF 01
.................... setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
01A5: MOVLW 05
01A6: BCF 03.5
01A7: MOVWF 10
.................... setup_timer_2(T2_DIV_BY_1,0xFF,1);
01A8: MOVLW 00
01A9: MOVWF 78
01AA: IORLW 04
01AB: MOVWF 12
01AC: MOVLW FF
01AD: BSF 03.5
01AE: MOVWF 12
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
01AF: BCF 03.5
01B0: BSF 03.6
01B1: CLRF 07
01B2: CLRF 08
01B3: CLRF 09
.................... // enable_interrupts(INT_RDA);
.................... enable_interrupts(INT_RTCC);
01B4: BCF 03.6
01B5: BSF 0B.5
.................... enable_interrupts(INT_TIMER1);
01B6: BSF 03.5
01B7: BSF 0C.0
.................... enable_interrupts(INT_TIMER2);
01B8: BSF 0C.1
.................... setup_oscillator(OSC_8MHZ);
01B9: MOVLW 71
01BA: MOVWF 0F
01BB: MOVF 0F,W
....................
.................... output_high(PIN_C3);
01BC: BCF 03.5
01BD: BCF 5C.3
01BE: MOVF 5C,W
01BF: BSF 03.5
01C0: MOVWF 07
01C1: BCF 03.5
01C2: BSF 07.3
.................... output_high(PIN_C5);
01C3: BCF 5C.5
01C4: MOVF 5C,W
01C5: BSF 03.5
01C6: MOVWF 07
01C7: BCF 03.5
01C8: BSF 07.5
....................
.................... dispdata[0] = 0xf1;
01C9: MOVLW F1
01CA: MOVWF 28
.................... dispdata[1] = 0xf2;
01CB: MOVLW F2
01CC: MOVWF 29
.................... dispdata[2] = 0xf4;
01CD: MOVLW F4
01CE: MOVWF 2A
.................... dispdata[3] = 0xf8;
01CF: MOVLW F8
01D0: MOVWF 2B
.................... dispdata[4] = 0xe0;
01D1: MOVLW E0
01D2: MOVWF 2C
.................... dispdata[5] = 0xd0;
01D3: MOVLW D0
01D4: MOVWF 2D
.................... dispdata[6] = 0xb0;
01D5: MOVLW B0
01D6: MOVWF 2E
.................... dispdata[7] = 0x70;
01D7: MOVLW 70
01D8: MOVWF 2F
....................
....................
.................... while(true)
.................... {
.................... output_high(PIN_B3);
01D9: BSF 03.5
01DA: BCF 06.3
01DB: BCF 03.5
01DC: BSF 06.3
.................... delay_ms(100);
01DD: MOVLW 64
01DE: MOVWF 5E
01DF: CALL 047
.................... output_low(PIN_B3);
01E0: BSF 03.5
01E1: BCF 06.3
01E2: BCF 03.5
01E3: BCF 06.3
.................... delay_ms(100);
01E4: MOVLW 64
01E5: MOVWF 5E
01E6: CALL 047
.................... Clear_LED();
01E7: GOTO 075
.................... Single_LED();
01E8: GOTO 091
.................... delay_ms(100);
01E9: MOVLW 64
01EA: MOVWF 5E
01EB: CALL 047
.................... Single_Line();
01EC: GOTO 0F3
01ED: GOTO 1D9
....................
.................... }
.................... }
01EE: GOTO 1EE
Configuration Fuses:
Word 1: 0CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP DEBUG
Word 2: 3FFF BORV40 NOWRT
Some fuses have been forced to be compatible with the ICD debugger.
|
So can anybody tell me the BIG Difference ???
Please be Aware in the non working code I just added one line in the main to get the Function "Single_Line" compiled and that is blowing the code !
BUT everything runs in CCS IDE fine ??
Best regards
Andreas |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 06, 2014 11:32 am |
|
|
You have the Protect fuse set:
Quote: | #include <16F886.h>
#device ICD=TRUE
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES PROTECT //Code protected from reads
#FUSES NOCPD //No EE protection
#FUSES BROWNOUT //Reset when brownout detected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG //Debug mode for use with ICD
#FUSES NOWRT //Program memory not write protected
#FUSES BORV40 //Brownout reset at 4.0V
#FUSES RESERVED //Used to set the reserved FUSE bits |
From the MPLAB Help file for the Pickit3, it says don't use Protect fuse
during debugging:
Quote: |
Top 10 Reasons Why You Can’t Debug
5. The device is code-protected. Check your Configuration bit’s setting for code protection |
|
|
|
|
|
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
|