![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
noyz
Joined: 31 Jan 2009 Posts: 59
|
3rd if in a while isn't taken in consideration |
Posted: Sat Jan 31, 2009 10:02 pm |
|
|
take a look at this:
Code: |
while (!input(PIN_C2)) {
if (!input(PIN_C3)) {cg();g('1');b=0;break;}
if (!input(PIN_D0)) {cg();g('3');b=0;break;}
if (!input(PIN_D1)) {cg();g('5');b=0;break;}
} |
That was exactly my code written. I thought that I did someting wrong on my electrical part... but everything was from the code and CCS.
With the following code my program works just fine:
Code: |
while (!input(PIN_C2)) {
if (!input(PIN_C3)) {cg();g('1');b=0;break;}
if (!input(PIN_D0)) {cg();g('3');b=0;break;}
break;
}
while (!input(PIN_C2)) {if (!input(PIN_D1)) {cg();g('5');b=0;break;} break;
}
|
I wonder why the 3rd if or line in a while isn't taken in consideration ??
Is there something wrong with my ccs ? |
|
![](templates/subSilver/images/spacer.gif) |
n-squared
Joined: 03 Oct 2006 Posts: 99
|
|
Posted: Sat Jan 31, 2009 10:37 pm |
|
|
I think the CCS forum message editor should contain a button for adding a standard text message:
"Please specify which processor and which compiler version you are using. Some header code would be appreciated. No more than 50 lines".
Maybe we will be better equipped to help you.
What you can do on your own is compile and look at the LST file to see if the compiler generated code for the third line.
Good luck _________________ Every solution has a problem. |
|
![](templates/subSilver/images/spacer.gif) |
noyz
Joined: 31 Jan 2009 Posts: 59
|
|
Posted: Sun Feb 01, 2009 1:33 pm |
|
|
i don't really understand what you are talking about
Code: |
#include <16F871.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=16 000 000) |
is this what u wanted me to write to you ?
sorry for my bad english :|
by the way i looked into the LST file and there isn't the 3rd if in the first case ori.. if i have if if if.. again the 3rd if isn't there... The same problem if i have if (()&&()&&()) |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Feb 01, 2009 1:48 pm |
|
|
I can't reproduce your observation with a minimal test program. (PCM v4.084)
Code: | #include <16F871.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=16 000 000)
void cg(void)
{
}
void g(char)
{
}
int8 b;
void main(void) {
while (!input(PIN_C2)) {
if (!input(PIN_C3)) {cg();g('1');b=0;break;}
if (!input(PIN_D0)) {cg();g('3');b=0;break;}
if (!input(PIN_D1)) {cg();g('5');b=0;break;}
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
noyz
Joined: 31 Jan 2009 Posts: 59
|
|
Posted: Mon Feb 02, 2009 3:57 pm |
|
|
i'm sorry but i've find out that in LST file is that if present. but it didn't work ... the first code with 2 while and max 2 if in while.. works.. this one i don't know why doesn't :
Code: | #include "C:\Documents and Settings\Noyz2k\My Documents\gear-display\PIC16F871.h"
void cg()
{
output_low(PIN_B7);
output_low(PIN_B6);
output_low(PIN_B5);
output_low(PIN_B4);
output_low(PIN_B3);
output_low(PIN_B2);
output_low(PIN_B1);
output_low(PIN_B0);
output_low(PIN_D7);
output_low(PIN_D6);
output_low(PIN_D5);
output_low(PIN_D4);
output_low(PIN_C7);
output_low(PIN_C6);
output_low(PIN_C5);
output_low(PIN_C4);
output_low(PIN_D3);
output_low(PIN_D2);
}
void g(char c)
{
if (c=='1')
{
output_high(PIN_D5);
output_high(PIN_D4);
output_high(PIN_C5);
}
if (c=='2')
{
output_high(PIN_B7);
output_high(PIN_B3);
output_high(PIN_B0);
output_high(PIN_D7);
output_high(PIN_D6);
output_high(PIN_D4);
output_high(PIN_C7);
output_high(PIN_D3);
}
if (c=='3')
{
output_high(PIN_D3);
output_high(PIN_C5);
output_high(PIN_C7);
output_high(PIN_D4);
output_high(PIN_D6);
output_high(PIN_D7);
output_high(PIN_B3);
output_high(PIN_B7);
}
if (c=='4')
{
output_high(PIN_C5);
output_high(PIN_C7);
output_high(PIN_D4);
output_high(PIN_B3);
output_high(PIN_B4);
}
if (c=='5')
{
output_high(PIN_D3);
output_high(PIN_C5);
output_high(PIN_C7);
output_high(PIN_D6);
output_high(PIN_D7);
output_high(PIN_B3);
output_high(PIN_B4);
output_high(PIN_B7);
}
if ((c=='r')||(c=='R'))
{
output_high(PIN_C6);
output_high(PIN_C7);
output_high(PIN_D4);
output_high(PIN_D6);
output_high(PIN_B0);
output_high(PIN_B3);
output_high(PIN_B4);
output_high(PIN_B7);
}
if ((c=='n')||(c=='N'))
{
output_high(PIN_C5);
output_high(PIN_C6);
output_high(PIN_D4);
output_high(PIN_B0);
output_high(PIN_B4);
output_high(PIN_B5);
}
}
void main()
{
int b,z=1;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
// TODO: USER CODE!!
cg();g('1');delay_ms(100);
cg();g('2');delay_ms(100);
cg();g('3');delay_ms(100);
cg();g('4');delay_ms(100);
cg();g('5');delay_ms(100);
cg();g('r');delay_ms(100);
cg();g('n');delay_ms(100);
output_high(PIN_A0);
output_high(PIN_A1);
output_high(PIN_A2);
output_high(PIN_A3);
output_high(PIN_A4);
output_high(PIN_A5);
delay_ms(1);
b=1;
while(TRUE)
{
if (b) {
while (!input(PIN_C2)) {
if (!input(PIN_C3)) {cg();g('1');b=0;break;}
if (!input(PIN_D0)) {cg();g('3');b=0;break;}
if (!input(PIN_D1)) {cg();g('5');b=0;break;}
break;
}
while (!input(PIN_C0)) {
if (!input(PIN_C3)) {cg();g('2');b=0;break;}
if (!input(PIN_D0)) {cg();g('4');b=0;break;}
if (!input(PIN_D1)) {cg();g('r');b=0;break;}
break;
}
}
if (!b)
{
if ((!input(PIN_C1))&&(input(PIN_C0))&&(input(PIN_C2))) {cg();g('n');b=1;}
}
if (z) {b=0;z=0;}
}
} | and the lst file : Code: | CCS PCM C Compiler, Version 4.057, 54385 02-Feb-09 23:41
Filename: C:\Documents and Settings\Noyz2k\My Documents\gear-display\PIC16F871.lst
ROM used: 591 words (29%)
Largest free fragment is 1457
RAM used: 8 (6%) at main() level
9 (7%) worst case
Stack: 1 locations
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 15E
0003: NOP
.................... #include "C:\Documents and Settings\Noyz2k\My Documents\gear-display\PIC16F871.h"
.................... #include <16F871.h>
.................... //////// Standard Header file for the PIC16F871 device ////////////////
.................... #device PIC16F871
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES XT //Crystal osc <= 4mhz
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES BROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
....................
.................... #use delay(clock=16 000 000)
*
014A: MOVLW 28
014B: MOVWF 04
014C: MOVF 00,W
014D: BTFSC 03.2
014E: GOTO 15D
014F: MOVLW 05
0150: MOVWF 21
0151: CLRF 20
0152: DECFSZ 20,F
0153: GOTO 152
0154: DECFSZ 21,F
0155: GOTO 151
0156: MOVLW 2E
0157: MOVWF 20
0158: DECFSZ 20,F
0159: GOTO 158
015A: GOTO 15B
015B: DECFSZ 00,F
015C: GOTO 14F
015D: RETLW 00
....................
....................
.................... void cg()
.................... {
.................... output_low(PIN_B7);
*
0004: BSF 03.5
0005: BCF 06.7
0006: BCF 03.5
0007: BCF 06.7
.................... output_low(PIN_B6);
0008: BSF 03.5
0009: BCF 06.6
000A: BCF 03.5
000B: BCF 06.6
.................... output_low(PIN_B5);
000C: BSF 03.5
000D: BCF 06.5
000E: BCF 03.5
000F: BCF 06.5
.................... output_low(PIN_B4);
0010: BSF 03.5
0011: BCF 06.4
0012: BCF 03.5
0013: BCF 06.4
.................... output_low(PIN_B3);
0014: BSF 03.5
0015: BCF 06.3
0016: BCF 03.5
0017: BCF 06.3
.................... output_low(PIN_B2);
0018: BSF 03.5
0019: BCF 06.2
001A: BCF 03.5
001B: BCF 06.2
.................... output_low(PIN_B1);
001C: BSF 03.5
001D: BCF 06.1
001E: BCF 03.5
001F: BCF 06.1
.................... output_low(PIN_B0);
0020: BSF 03.5
0021: BCF 06.0
0022: BCF 03.5
0023: BCF 06.0
.................... output_low(PIN_D7);
0024: BSF 03.5
0025: BCF 08.7
0026: BCF 03.5
0027: BCF 08.7
.................... output_low(PIN_D6);
0028: BSF 03.5
0029: BCF 08.6
002A: BCF 03.5
002B: BCF 08.6
.................... output_low(PIN_D5);
002C: BSF 03.5
002D: BCF 08.5
002E: BCF 03.5
002F: BCF 08.5
.................... output_low(PIN_D4);
0030: BSF 03.5
0031: BCF 08.4
0032: BCF 03.5
0033: BCF 08.4
.................... output_low(PIN_C7);
0034: BCF 25.7
0035: MOVF 25,W
0036: BSF 03.5
0037: MOVWF 07
0038: BCF 03.5
0039: BCF 07.7
*
0166: MOVLW FF
0167: BCF 03.5
0168: MOVWF 25
.................... output_low(PIN_C6);
*
003A: BCF 25.6
003B: MOVF 25,W
003C: BSF 03.5
003D: MOVWF 07
003E: BCF 03.5
003F: BCF 07.6
.................... output_low(PIN_C5);
0040: BCF 25.5
0041: MOVF 25,W
0042: BSF 03.5
0043: MOVWF 07
0044: BCF 03.5
0045: BCF 07.5
.................... output_low(PIN_C4);
0046: BCF 25.4
0047: MOVF 25,W
0048: BSF 03.5
0049: MOVWF 07
004A: BCF 03.5
004B: BCF 07.4
.................... output_low(PIN_D3);
004C: BSF 03.5
004D: BCF 08.3
004E: BCF 03.5
004F: BCF 08.3
.................... output_low(PIN_D2);
0050: BSF 03.5
0051: BCF 08.2
0052: BCF 03.5
0053: BCF 08.2
.................... }
0054: RETLW 00
.................... void g(char c)
.................... {
.................... if (c=='1')
0055: MOVF 28,W
0056: SUBLW 31
0057: BTFSS 03.2
0058: GOTO 067
....................
.................... {
.................... output_high(PIN_D5);
0059: BSF 03.5
005A: BCF 08.5
005B: BCF 03.5
005C: BSF 08.5
.................... output_high(PIN_D4);
005D: BSF 03.5
005E: BCF 08.4
005F: BCF 03.5
0060: BSF 08.4
.................... output_high(PIN_C5);
0061: BCF 25.5
0062: MOVF 25,W
0063: BSF 03.5
0064: MOVWF 07
0065: BCF 03.5
0066: BSF 07.5
.................... }
.................... if (c=='2')
0067: MOVF 28,W
0068: SUBLW 32
0069: BTFSS 03.2
006A: GOTO 08D
.................... {
.................... output_high(PIN_B7);
006B: BSF 03.5
006C: BCF 06.7
006D: BCF 03.5
006E: BSF 06.7
.................... output_high(PIN_B3);
006F: BSF 03.5
0070: BCF 06.3
0071: BCF 03.5
0072: BSF 06.3
.................... output_high(PIN_B0);
0073: BSF 03.5
0074: BCF 06.0
0075: BCF 03.5
0076: BSF 06.0
.................... output_high(PIN_D7);
0077: BSF 03.5
0078: BCF 08.7
0079: BCF 03.5
007A: BSF 08.7
.................... output_high(PIN_D6);
007B: BSF 03.5
007C: BCF 08.6
007D: BCF 03.5
007E: BSF 08.6
.................... output_high(PIN_D4);
007F: BSF 03.5
0080: BCF 08.4
0081: BCF 03.5
0082: BSF 08.4
.................... output_high(PIN_C7);
0083: BCF 25.7
0084: MOVF 25,W
0085: BSF 03.5
0086: MOVWF 07
0087: BCF 03.5
0088: BSF 07.7
.................... output_high(PIN_D3);
0089: BSF 03.5
008A: BCF 08.3
008B: BCF 03.5
008C: BSF 08.3
.................... }
.................... if (c=='3')
008D: MOVF 28,W
008E: SUBLW 33
008F: BTFSS 03.2
0090: GOTO 0B5
.................... {
.................... output_high(PIN_D3);
0091: BSF 03.5
0092: BCF 08.3
0093: BCF 03.5
0094: BSF 08.3
.................... output_high(PIN_C5);
0095: BCF 25.5
0096: MOVF 25,W
0097: BSF 03.5
0098: MOVWF 07
0099: BCF 03.5
009A: BSF 07.5
.................... output_high(PIN_C7);
009B: BCF 25.7
009C: MOVF 25,W
009D: BSF 03.5
009E: MOVWF 07
009F: BCF 03.5
00A0: BSF 07.7
.................... output_high(PIN_D4);
00A1: BSF 03.5
00A2: BCF 08.4
00A3: BCF 03.5
00A4: BSF 08.4
.................... output_high(PIN_D6);
00A5: BSF 03.5
00A6: BCF 08.6
00A7: BCF 03.5
00A8: BSF 08.6
.................... output_high(PIN_D7);
00A9: BSF 03.5
00AA: BCF 08.7
00AB: BCF 03.5
00AC: BSF 08.7
.................... output_high(PIN_B3);
00AD: BSF 03.5
00AE: BCF 06.3
00AF: BCF 03.5
00B0: BSF 06.3
.................... output_high(PIN_B7);
00B1: BSF 03.5
00B2: BCF 06.7
00B3: BCF 03.5
00B4: BSF 06.7
.................... }
.................... if (c=='4')
00B5: MOVF 28,W
00B6: SUBLW 34
00B7: BTFSS 03.2
00B8: GOTO 0D1
.................... {
.................... output_high(PIN_C5);
00B9: BCF 25.5
00BA: MOVF 25,W
00BB: BSF 03.5
00BC: MOVWF 07
00BD: BCF 03.5
00BE: BSF 07.5
.................... output_high(PIN_C7);
00BF: BCF 25.7
00C0: MOVF 25,W
00C1: BSF 03.5
00C2: MOVWF 07
00C3: BCF 03.5
00C4: BSF 07.7
.................... output_high(PIN_D4);
00C5: BSF 03.5
00C6: BCF 08.4
00C7: BCF 03.5
00C8: BSF 08.4
.................... output_high(PIN_B3);
00C9: BSF 03.5
00CA: BCF 06.3
00CB: BCF 03.5
00CC: BSF 06.3
.................... output_high(PIN_B4);
00CD: BSF 03.5
00CE: BCF 06.4
00CF: BCF 03.5
00D0: BSF 06.4
.................... }
.................... if (c=='5')
00D1: MOVF 28,W
00D2: SUBLW 35
00D3: BTFSS 03.2
00D4: GOTO 0F9
.................... {
.................... output_high(PIN_D3);
00D5: BSF 03.5
00D6: BCF 08.3
00D7: BCF 03.5
00D8: BSF 08.3
.................... output_high(PIN_C5);
00D9: BCF 25.5
00DA: MOVF 25,W
00DB: BSF 03.5
00DC: MOVWF 07
00DD: BCF 03.5
00DE: BSF 07.5
.................... output_high(PIN_C7);
00DF: BCF 25.7
00E0: MOVF 25,W
00E1: BSF 03.5
00E2: MOVWF 07
00E3: BCF 03.5
00E4: BSF 07.7
.................... output_high(PIN_D6);
00E5: BSF 03.5
00E6: BCF 08.6
00E7: BCF 03.5
00E8: BSF 08.6
.................... output_high(PIN_D7);
00E9: BSF 03.5
00EA: BCF 08.7
00EB: BCF 03.5
00EC: BSF 08.7
.................... output_high(PIN_B3);
00ED: BSF 03.5
00EE: BCF 06.3
00EF: BCF 03.5
00F0: BSF 06.3
.................... output_high(PIN_B4);
00F1: BSF 03.5
00F2: BCF 06.4
00F3: BCF 03.5
00F4: BSF 06.4
.................... output_high(PIN_B7);
00F5: BSF 03.5
00F6: BCF 06.7
00F7: BCF 03.5
00F8: BSF 06.7
.................... }
.................... if ((c=='r')||(c=='R'))
00F9: MOVF 28,W
00FA: SUBLW 72
00FB: BTFSC 03.2
00FC: GOTO 101
00FD: MOVF 28,W
00FE: SUBLW 52
00FF: BTFSS 03.2
0100: GOTO 125
.................... {
.................... output_high(PIN_C6);
0101: BCF 25.6
0102: MOVF 25,W
0103: BSF 03.5
0104: MOVWF 07
0105: BCF 03.5
0106: BSF 07.6
.................... output_high(PIN_C7);
0107: BCF 25.7
0108: MOVF 25,W
0109: BSF 03.5
010A: MOVWF 07
010B: BCF 03.5
010C: BSF 07.7
.................... output_high(PIN_D4);
010D: BSF 03.5
010E: BCF 08.4
010F: BCF 03.5
0110: BSF 08.4
.................... output_high(PIN_D6);
0111: BSF 03.5
0112: BCF 08.6
0113: BCF 03.5
0114: BSF 08.6
.................... output_high(PIN_B0);
0115: BSF 03.5
0116: BCF 06.0
0117: BCF 03.5
0118: BSF 06.0
.................... output_high(PIN_B3);
0119: BSF 03.5
011A: BCF 06.3
011B: BCF 03.5
011C: BSF 06.3
.................... output_high(PIN_B4);
011D: BSF 03.5
011E: BCF 06.4
011F: BCF 03.5
0120: BSF 06.4
.................... output_high(PIN_B7);
0121: BSF 03.5
0122: BCF 06.7
0123: BCF 03.5
0124: BSF 06.7
.................... }
.................... if ((c=='n')||(c=='N'))
0125: MOVF 28,W
0126: SUBLW 6E
0127: BTFSC 03.2
0128: GOTO 12D
0129: MOVF 28,W
012A: SUBLW 4E
012B: BTFSS 03.2
012C: GOTO 149
.................... {
.................... output_high(PIN_C5);
012D: BCF 25.5
012E: MOVF 25,W
012F: BSF 03.5
0130: MOVWF 07
0131: BCF 03.5
0132: BSF 07.5
.................... output_high(PIN_C6);
0133: BCF 25.6
0134: MOVF 25,W
0135: BSF 03.5
0136: MOVWF 07
0137: BCF 03.5
0138: BSF 07.6
.................... output_high(PIN_D4);
0139: BSF 03.5
013A: BCF 08.4
013B: BCF 03.5
013C: BSF 08.4
.................... output_high(PIN_B0);
013D: BSF 03.5
013E: BCF 06.0
013F: BCF 03.5
0140: BSF 06.0
.................... output_high(PIN_B4);
0141: BSF 03.5
0142: BCF 06.4
0143: BCF 03.5
0144: BSF 06.4
.................... output_high(PIN_B5);
0145: BSF 03.5
0146: BCF 06.5
0147: BCF 03.5
0148: BSF 06.5
.................... }
.................... }
0149: RETLW 00
....................
.................... void main()
.................... {
*
015E: CLRF 04
015F: MOVLW 1F
0160: ANDWF 03,F
0161: BSF 03.5
0162: BSF 1F.0
0163: BSF 1F.1
0164: BSF 1F.2
0165: BCF 1F.3
.................... int b,z=1;
*
0169: MOVLW 01
016A: MOVWF 27
.................... setup_adc_ports(NO_ANALOGS);
016B: BSF 03.5
016C: BSF 1F.0
016D: BSF 1F.1
016E: BSF 1F.2
016F: BCF 1F.3
.................... setup_adc(ADC_OFF);
0170: BCF 03.5
0171: BCF 1F.0
.................... setup_psp(PSP_DISABLED);
0172: BSF 03.5
0173: BCF 09.4
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
0174: MOVF 01,W
0175: ANDLW C7
0176: IORLW 08
0177: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0178: BCF 03.5
0179: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
017A: MOVLW 00
017B: MOVWF 21
017C: MOVWF 12
017D: MOVLW 00
017E: BSF 03.5
017F: MOVWF 12
....................
.................... // TODO: USER CODE!!
.................... cg();g('1');delay_ms(100);
0180: BCF 03.5
0181: CALL 004
0182: MOVLW 31
0183: MOVWF 28
0184: CALL 055
0185: MOVLW 64
0186: MOVWF 28
0187: CALL 14A
.................... cg();g('2');delay_ms(100);
0188: CALL 004
0189: MOVLW 32
018A: MOVWF 28
018B: CALL 055
018C: MOVLW 64
018D: MOVWF 28
018E: CALL 14A
.................... cg();g('3');delay_ms(100);
018F: CALL 004
0190: MOVLW 33
0191: MOVWF 28
0192: CALL 055
0193: MOVLW 64
0194: MOVWF 28
0195: CALL 14A
.................... cg();g('4');delay_ms(100);
0196: CALL 004
0197: MOVLW 34
0198: MOVWF 28
0199: CALL 055
019A: MOVLW 64
019B: MOVWF 28
019C: CALL 14A
.................... cg();g('5');delay_ms(100);
019D: CALL 004
019E: MOVLW 35
019F: MOVWF 28
01A0: CALL 055
01A1: MOVLW 64
01A2: MOVWF 28
01A3: CALL 14A
.................... cg();g('r');delay_ms(100);
01A4: CALL 004
01A5: MOVLW 72
01A6: MOVWF 28
01A7: CALL 055
01A8: MOVLW 64
01A9: MOVWF 28
01AA: CALL 14A
.................... cg();g('n');delay_ms(100);
01AB: CALL 004
01AC: MOVLW 6E
01AD: MOVWF 28
01AE: CALL 055
01AF: MOVLW 64
01B0: MOVWF 28
01B1: CALL 14A
....................
.................... output_high(PIN_A0);
01B2: BSF 03.5
01B3: BCF 05.0
01B4: BCF 03.5
01B5: BSF 05.0
.................... output_high(PIN_A1);
01B6: BSF 03.5
01B7: BCF 05.1
01B8: BCF 03.5
01B9: BSF 05.1
.................... output_high(PIN_A2);
01BA: BSF 03.5
01BB: BCF 05.2
01BC: BCF 03.5
01BD: BSF 05.2
.................... output_high(PIN_A3);
01BE: BSF 03.5
01BF: BCF 05.3
01C0: BCF 03.5
01C1: BSF 05.3
.................... output_high(PIN_A4);
01C2: BSF 03.5
01C3: BCF 05.4
01C4: BCF 03.5
01C5: BSF 05.4
.................... output_high(PIN_A5);
01C6: BSF 03.5
01C7: BCF 05.5
01C8: BCF 03.5
01C9: BSF 05.5
.................... delay_ms(1);
01CA: MOVLW 01
01CB: MOVWF 28
01CC: CALL 14A
.................... b=1;
01CD: MOVLW 01
01CE: MOVWF 26
.................... while(TRUE)
.................... {
....................
.................... if (b) {
01CF: MOVF 26,F
01D0: BTFSC 03.2
01D1: GOTO 22A
.................... while (!input(PIN_C2)) {
01D2: BSF 25.2
01D3: MOVF 25,W
01D4: BSF 03.5
01D5: MOVWF 07
01D6: BCF 03.5
01D7: BTFSC 07.2
01D8: GOTO 1FE
.................... if (!input(PIN_C3)) {cg();g('1');b=0;break;}
01D9: BSF 25.3
01DA: MOVF 25,W
01DB: BSF 03.5
01DC: MOVWF 07
01DD: BCF 03.5
01DE: BTFSC 07.3
01DF: GOTO 1E6
01E0: CALL 004
01E1: MOVLW 31
01E2: MOVWF 28
01E3: CALL 055
01E4: CLRF 26
01E5: GOTO 1FE
.................... if (!input(PIN_D0)) {cg();g('3');b=0;break;}
01E6: BSF 03.5
01E7: BSF 08.0
01E8: BCF 03.5
01E9: BTFSC 08.0
01EA: GOTO 1F1
01EB: CALL 004
01EC: MOVLW 33
01ED: MOVWF 28
01EE: CALL 055
01EF: CLRF 26
01F0: GOTO 1FE
.................... if (!input(PIN_D1)) {cg();g('5');b=0;break;}
01F1: BSF 03.5
01F2: BSF 08.1
01F3: BCF 03.5
01F4: BTFSC 08.1
01F5: GOTO 1FC
01F6: CALL 004
01F7: MOVLW 35
01F8: MOVWF 28
01F9: CALL 055
01FA: CLRF 26
01FB: GOTO 1FE
.................... break;
01FC: GOTO 1FE
.................... }
01FD: GOTO 1D2
.................... while (!input(PIN_C0)) {
01FE: BSF 25.0
01FF: MOVF 25,W
0200: BSF 03.5
0201: MOVWF 07
0202: BCF 03.5
0203: BTFSC 07.0
0204: GOTO 22A
.................... if (!input(PIN_C3)) {cg();g('2');b=0;break;}
0205: BSF 25.3
0206: MOVF 25,W
0207: BSF 03.5
0208: MOVWF 07
0209: BCF 03.5
020A: BTFSC 07.3
020B: GOTO 212
020C: CALL 004
020D: MOVLW 32
020E: MOVWF 28
020F: CALL 055
0210: CLRF 26
0211: GOTO 22A
.................... if (!input(PIN_D0)) {cg();g('4');b=0;break;}
0212: BSF 03.5
0213: BSF 08.0
0214: BCF 03.5
0215: BTFSC 08.0
0216: GOTO 21D
0217: CALL 004
0218: MOVLW 34
0219: MOVWF 28
021A: CALL 055
021B: CLRF 26
021C: GOTO 22A
.................... if (!input(PIN_D1)) {cg();g('r');b=0;break;}
021D: BSF 03.5
021E: BSF 08.1
021F: BCF 03.5
0220: BTFSC 08.1
0221: GOTO 228
0222: CALL 004
0223: MOVLW 72
0224: MOVWF 28
0225: CALL 055
0226: CLRF 26
0227: GOTO 22A
.................... break;
0228: GOTO 22A
.................... }
0229: GOTO 1FE
.................... }
....................
....................
.................... if (!b)
022A: MOVF 26,F
022B: BTFSS 03.2
022C: GOTO 248
.................... {
.................... if ((!input(PIN_C1))&&(input(PIN_C0))&&(input(PIN_C2))) {cg();g('n');b=1;}
022D: BSF 25.1
022E: MOVF 25,W
022F: BSF 03.5
0230: MOVWF 07
0231: BCF 03.5
0232: BTFSC 07.1
0233: GOTO 248
0234: BSF 25.0
0235: MOVF 25,W
0236: BSF 03.5
0237: MOVWF 07
0238: BCF 03.5
0239: BTFSS 07.0
023A: GOTO 248
023B: BSF 25.2
023C: MOVF 25,W
023D: BSF 03.5
023E: MOVWF 07
023F: BCF 03.5
0240: BTFSS 07.2
0241: GOTO 248
0242: CALL 004
0243: MOVLW 6E
0244: MOVWF 28
0245: CALL 055
0246: MOVLW 01
0247: MOVWF 26
.................... }
.................... if (z) {b=0;z=0;}
0248: MOVF 27,F
0249: BTFSC 03.2
024A: GOTO 24D
024B: CLRF 26
024C: CLRF 27
.................... }
024D: GOTO 1CF
.................... }
024E: SLEEP
Configuration Fuses:
Word 1: 3F79 XT NOWDT NOPUT NOPROTECT NODEBUG BROWNOUT NOLVP NOCPD NOWRT
|
http://noyz2k.com/gear/MOV03448.avi this is what i'm working about
i'm not using demultiplexer because i hate the flikering rate.. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Feb 02, 2009 4:10 pm |
|
|
The listing is right.
If it isn't doing what you expect, then your code is wrong, or your signals aren't behaving as you think they are.
Code: |
.................... if (!input(PIN_D0)) {cg();g('3');b=0;break;}
//set TRIS high for D0
01E6: BSF 03.5
01E7: BSF 08.0
01E8: BCF 03.5
//Read pin - if it is high, skip to address 1F1
01E9: BTFSC 08.0
01EA: GOTO 1F1
01EB: CALL 004 //This is the call to 'cg'
01EC: MOVLW 33 //ASCII '3'
01ED: MOVWF 28
01EE: CALL 055 //call to 'g'
01EF: CLRF 26 //set b=0
01F0: GOTO 1FE
.................... if (!input(PIN_D1)) {cg();g('5');b=0;break;}
//Correctly gets here if D0 was high
01F1: BSF 03.5 //Now set tris for D1
01F2: BSF 08.1
01F3: BCF 03.5
01F4: BTFSC 08.1 //and test D1
01F5: GOTO 1FC
01F6: CALL 004
01F7: MOVLW 35
01F8: MOVWF 28
01F9: CALL 055
01FA: CLRF 26
01FB: GOTO 1FE
|
Seriously, you have something else wrong. Classic example, would be something like the actual 'high' level on the pins, not quite being 'high'.
The third section of code, _will_ be called, if D0 is high and D1 is low.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|