CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Functions not compiling

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ivan
Guest







Functions not compiling
PostPosted: Sun Oct 14, 2001 9:59 am     Reply with quote

Hello, I just received the pcm compiler for linux version 3.046. I am trying to get a program to compile with a function that is called. When I look at the .LST file, the only assembler instruction for the function is RETLW 00. I'm new to this compiler and haven't figured out what could be causing this. Below is my code. The function that doesn't work is shift_out(char a)

Ivan

#include <16c77.h>
#include <string.h>

#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)

#define WIRE1 PIN_E0
#define WIRE2 PIN_E1
#define WIRE3 PIN_E2

unsigned byte ptr;
char i;

byte ex_charge;


long timetag_lo; /* 1200 Hz clock */
long timetag_hi; /* 1 second clock */
long timetag_top; /* upper half on 1 second clock */
char *adr; /* address pointer */
char shift_reg;


char shift_out(char a) {
char ip;
char temp1;
for(ip = 0; ip< 8;ip++) {
output_low(PIN_D5);
temp1 = (a >> ip) & 0x01;
if(temp1 == 1) output_high(PIN_D6);
else output_low(PIN_D6);
output_high(PIN_D5);
}
output_low(PIN_D5);
output_high(PIN_D7);
output_low(PIN_D7);
return(0);
}

main()
{

/* Configure the ports */
#use fast_io(A) /* set A port IO */
set_tris_a(0x3f);
#use fast_io(B) /* set B port IO */
set_tris_b(0x3f);
#use fast_io(C) /* set C port IO */
set_tris_c(0x92);
#use fast_io(D)
set_tris_d(0x0f);
#use fast_io(E)
set_tris_e(0x07);
output_low(PIN_E0);
output_low(PIN_E1);
output_low(PIN_E2);
adr = 0x06;
shift_reg = 0x46;
shift_out(shift_reg);

if(input(PIN_B5) == 1) ex_charge = 1;
else ex_charge = 0;


/* set timer to interrupt at 1200 Hz */
setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
enable_interrupts(INT_TIMER1); /* enable timer1 interrupt */
set_timer1(65336);
ptr = 0;

timetag_lo = 0;
timetag_hi = 0;
timetag_top = 0;
shift_reg = shift_reg | 0x03;
shift_out(shift_reg);

for(i=0;i<200;i++) {
delay_ms(500);
shift_reg = shift_reg ^ 1;
shift_out(shift_reg);
}
while(1);

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 656
Phil



Joined: 09 Sep 2003
Posts: 12

View user's profile Send private message

Re: Functions not compiling
PostPosted: Sun Oct 14, 2001 10:23 am     Reply with quote

Could you post your list file?

Thanks,
Phil

:=Hello, I just received the pcm compiler for linux version 3.046. I am trying to get a program to compile with a function that is called. When I look at the .LST file, the only assembler instruction for the function is RETLW 00. I'm new to this compiler and haven't figured out what could be causing this. Below is my code. The function that doesn't work is shift_out(char a)
:=
:=Ivan
:=
:=#include <16c77.h>
:=#include <string.h>
:=
:=#use delay(clock=4000000)
:=#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
:=
:=#define WIRE1 PIN_E0
:=#define WIRE2 PIN_E1
:=#define WIRE3 PIN_E2
:=
:=unsigned byte ptr;
:=char i;
:=
:=byte ex_charge;
:=
:=
:=long timetag_lo; /* 1200 Hz clock */
:=long timetag_hi; /* 1 second clock */
:=long timetag_top; /* upper half on 1 second clock */
:=char *adr; /* address pointer */
:=char shift_reg;
:=
:=
:=char shift_out(char a) {
:=char ip;
:=char temp1;
:= for(ip = 0; ip< 8;ip++) {
:= output_low(PIN_D5);
:= temp1 = (a >> ip) & 0x01;
:= if(temp1 == 1) output_high(PIN_D6);
:= else output_low(PIN_D6);
:= output_high(PIN_D5);
:= }
:= output_low(PIN_D5);
:= output_high(PIN_D7);
:= output_low(PIN_D7);
:= return(0);
:=}
:=
:=main()
:={
:=
:=/* Configure the ports */
:=#use fast_io(A) /* set A port IO */
:= set_tris_a(0x3f);
:=#use fast_io(B) /* set B port IO */
:= set_tris_b(0x3f);
:=#use fast_io(C) /* set C port IO */
:= set_tris_c(0x92);
:=#use fast_io(D)
:= set_tris_d(0x0f);
:=#use fast_io(E)
:= set_tris_e(0x07);
:= output_low(PIN_E0);
:= output_low(PIN_E1);
:= output_low(PIN_E2);
:= adr = 0x06;
:= shift_reg = 0x46;
:= shift_out(shift_reg);
:=
:= if(input(PIN_B5) == 1) ex_charge = 1;
:= else ex_charge = 0;
:=
:=
:=/* set timer to interrupt at 1200 Hz */
:= setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
:= enable_interrupts(INT_TIMER1); /* enable timer1 interrupt */
:= set_timer1(65336);
:= ptr = 0;
:=
:= timetag_lo = 0;
:= timetag_hi = 0;
:= timetag_top = 0;
:= shift_reg = shift_reg | 0x03;
:= shift_out(shift_reg);
:=
:= for(i=0;i<200;i++) {
:= delay_ms(500);
:= shift_reg = shift_reg ^ 1;
:= shift_out(shift_reg);
:= }
:= while(1);
:=
:=}
___________________________
This message was ported from CCS's old forum
Original Post ID: 657
Ivan
Guest







Re: Functions not compiling
PostPosted: Sun Oct 14, 2001 10:42 am     Reply with quote

:=Could you post your list file?
:=
:=Thanks,
:=Phil
:=


Here is the list file.

Ivan

CCS PCW C Compiler, Version 3.046, 12830

Filename: /usr/picc/cube7.LST

ROM used: 20 (0\%)
Largest free fragment is 2048
RAM used: 18 (10\%) at main() level
21 (12\%) worst case
Stack: 1 locations

*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 008
0003: NOP
.................... #include <16c77.h>
.................... //////// Standard Header file for the PIC16C77 device ////////////////
.................... #device PIC16C77
.................... #list
....................
.................... #include <string.h>
.................... ////////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,1997 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. ////
.................... ////////////////////////////////////////////////////////////////////////////
....................
.................... #include <ctype.h>
.................... //// (C) Copyright 1996,1997 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. ////
.................... ////////////////////////////////////////////////////////////////////////////
.................... #list
....................
....................
.................... /* standard template: char *strcat(char *s1, const char *s2) */
....................
.................... char strcat(char *s1, char *s2)
.................... {
.................... char *s;
....................
.................... for (s = s1; *s != '\0'; s++);
.................... while ((*s = *s2) != '\0')
.................... {
.................... s++;
.................... s2++;
.................... }
.................... return(s1);
.................... }
....................
.................... /***********************************************************/
....................
.................... /* standard template: char *strchr(const char *s, int c).
.................... Finds first occurrence of c in s1 */
....................
.................... char strchr(char *s, int c)
.................... {
.................... for (; *s != c; s++)
.................... if (*s == '\0')
.................... return(0);
.................... return(s);
.................... }
....................
.................... /* standard template: char *strrchr(const char *s, int c).
.................... Finds last occurrence of c in s1 */
....................
.................... char strrchr(char *s, int c)
.................... {
.................... char *p;
....................
.................... for (p = 0; ; s++)
.................... {
.................... if (*s == c)
.................... p = s;
.................... if (*s == '\0')
.................... return(p);
.................... }
.................... }
....................
.................... /*****************************************************************/
....................
.................... /* standard template: int strcmp(const char *s1, const char *s2).
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
....................
.................... signed int strcmp(char *s1, char *s2)
.................... {
.................... for (; *s1 == *s2; s1++, s2++)
.................... if (*s1 == '\0')
.................... return(0);
.................... return((*s1 < *s2) ? -1: 1);
.................... }
....................
.................... /* standard template:
.................... int strncmp(const char *s1, const char *s2, size_t n).
.................... Compares max of n characters (not following 0) from s1 to s2;
.................... returns same as strcmp */
....................
.................... signed int strncmp(char *s1, char *s2, int n)
.................... {
.................... for (; n > 0; s1++, s2++, n--)
.................... if (*s1 != *s2)
.................... return((*s1 <*s2) ? -1: 1);
.................... else if (*s1 == '\0')
.................... return(0);
.................... return(0);
.................... }
....................
.................... /* standard template: size_t stricmp(const char *s1, const char *s2).
.................... Compares s1 to s2 ignoring case (upper vs. lower) */
....................
.................... signed int stricmp(char *s1, char *s2)
.................... {
.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));
.................... s1++, s2++)
.................... if (*s1 == '\0')
.................... return(0);
.................... return((*s1 < *s2) ? -1: 1);
.................... }
....................
.................... /***************************************************************/
....................
.................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved?
.................... Standard template: char *strcpy(char *s1, const char *s2) */
....................
.................... char strcopy(char *s1, char *s2)
.................... {
.................... char *s;
....................
.................... for (s = s1; *s2 != 0; s++, s2++)
.................... *s = *s2;
.................... return(s1);
.................... }
....................
.................... /* standard template:
.................... char *strncpy(char *s1, const char *s2, size_t n).
.................... Copies max of n characters (not following ending '\0')
.................... from s2 in s1; if s2 has less than n characters, appends 0 */
....................
.................... char strncpy(char *s1, char *s2, int n)
.................... {
.................... char *s;
....................
.................... for (s = s1; n > 0 && *s2 != '\0'; n--)
.................... *s++ = *s2++;
.................... for (; n > 0; n--)
.................... *s++ = '\0';
....................
.................... return(s1);
.................... }
....................
.................... /***************************************************************/
....................
.................... /* standard template:
.................... size_t strcspn(const char *s1, const char *s2).
.................... Computes length of max initial segment of s1 that
.................... consists entirely of characters NOT from s2*/
....................
.................... int strcspn(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
.................... for (sc2 = s2; *sc2 != 0; sc2++)
.................... if (*sc1 == *sc2)
.................... return(sc1 - s1);
.................... return(sc1 - s1);
.................... }
....................
.................... /* computes length of max initial segment of s1 consisting
.................... entirely of characters from s2 */
....................
.................... int strspn(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
.................... for (sc2 = s2; ; sc2++)
.................... if (*sc2 == '\0')
.................... return(sc1 - s1);
.................... else if (*sc1 == *sc2)
.................... break;
.................... return(sc1 - s1);
.................... }
....................
.................... /***************************************************************/
....................
.................... /* standard template: size_t strlen(const char *s).
.................... Computes length of s1 (preceding terminating 0) */
....................
.................... int strlen(char *s)
.................... {
.................... char *sc;
....................
.................... for (sc = s; *sc != 0; sc++);
.................... return(sc - s);
.................... }
....................
.................... /***************************************************************/
....................
.................... /* standard template: char *strlwr(char *s).
.................... Replaces uppercase letters by lowercase;
.................... returns pointer to new string s */
....................
.................... char strlwr(char *s)
.................... {
.................... char *p;
....................
.................... for (p = s; *p != '\0'; p++)
.................... if (*p >= 'A' && *p <='Z')
.................... *p += 'a' - 'A';
.................... return(s);
.................... }
....................
.................... /****************************************************************/
....................
.................... /* standard template:
.................... char *strpbrk(const char *s1, const char *s2).
.................... Locates first occurence of any character from s2 in s1;
.................... returns s1 if s2 is empty string */
....................
.................... char strpbrk(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... for (sc1 = s1; *sc1 != 0; sc1++)
.................... for (sc2 = s2; *sc2 != 0; sc2++)
.................... if (*sc1 == *sc2)
.................... return(sc1);
.................... return(0);
.................... }
....................
.................... /****************************************************************/
....................
.................... /* standard template:
.................... char *strstr(const char *s1, const char *s2);
.................... Locates first occurence of character sequence s2 in s1;
.................... returns 0 if s2 is empty string */
....................
.................... char strstr(char *s1, char *s2)
.................... {
.................... char *sc1, *sc2;
....................
.................... if (*s2 == 0)
.................... return(s1);
.................... for (; s1 = strchr(s1, *s2); s1++)
.................... {
.................... for (sc1 = s1, sc2 = s2; ; sc1++, sc2++)
.................... if (*sc2 == 0)
.................... return(s1);
.................... else if (*sc1 != *sc2)
.................... break;
.................... }
.................... return(0);
.................... }
....................
.................... /************************************************************/
....................
.................... /* standard template: char *strtok(char *s1, const char *s2).
....................
.................... Finds next token in s1 delimited by a character from separator
.................... string s2 (which can be different from call to call). First call
.................... starts at beginning of s1 searching for first character NOT
.................... contained in s2; returns 0 if none is found.
.................... If one is found, it is the start of first token (return value).
.................... Function then searches from there for a character contained in s2.
.................... If none is found, current token extends to end of s1, and subsequent
.................... searches for a token will return 0. If one is found, it is
.................... overwritten by '\0', which terminates current token. Function saves
.................... pointer to following character from which next search will start.
.................... Each subsequent call, with 0 as first argument, starts searching
.................... from saved pointer */
....................
.................... char strtok(char *s1, char *s2)
.................... {
.................... char *beg, *end;
.................... static char *save;
....................
.................... beg = (s1)? s1: save;
.................... beg += strspn(beg, s2);
.................... if (*beg == '\0')
.................... {
.................... *save = ' ';
.................... return(0);
.................... }
.................... end = strpbrk(beg, s2);
.................... if (*end != '\0')
.................... {
.................... *end = '\0';
.................... end++;
.................... }
.................... save = end;
.................... return(beg);
.................... }
....................
....................
....................
.................... #use delay(clock=4000000)
*
0005: BCF 0A.3
0006: BCF 0A.4
0007: GOTO 010 (RETURN)
.................... #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
....................
.................... #define WIRE1 PIN_E0
.................... #define WIRE2 PIN_E1
.................... #define WIRE3 PIN_E2
....................
.................... unsigned byte ptr;
.................... char i;
....................
.................... byte ex_charge;
....................
....................
.................... long timetag_lo; /* 1200 Hz clock */
.................... long timetag_hi; /* 1 second clock */
.................... long timetag_top; /* upper half on 1 second clock */
.................... char *adr; /* address pointer */
.................... char shift_reg;
....................
....................
.................... char shift_out(char a) {
.................... char ip;
.................... char temp1;
.................... for(ip = 0; ip< 8;ip++) {
.................... output_low(PIN_D5);
.................... temp1 = (a >> ip) & 0x01;
.................... if(temp1 == 1) output_high(PIN_D6);
.................... else output_low(PIN_D6);
.................... output_high(PIN_D5);
.................... }
.................... output_low(PIN_D5);
.................... output_high(PIN_D7);
.................... output_low(PIN_D7);
.................... return(0);
*
0004: RETLW 00
.................... }
....................
.................... main()
.................... {
....................
.................... /* Configure the ports */
.................... #use fast_io(A) /* set A port IO */
.................... set_tris_a(0x3f);
.................... #use fast_io(B) /* set B port IO */
.................... set_tris_b(0x3f);
.................... #use fast_io(C) /* set C port IO */
.................... set_tris_c(0x92);
.................... #use fast_io(D)
.................... set_tris_d(0x0f);
.................... #use fast_io(E)
.................... set_tris_e(0x07);
.................... output_low(PIN_E0);
.................... output_low(PIN_E1);
.................... output_low(PIN_E2);
.................... adr = 0x06;
.................... shift_reg = 0x46;
.................... shift_out(shift_reg);
*
0008: MOVF 2B,W
0009: MOVWF 2C
000A: CALL 004
....................
.................... if(input(PIN_B5) == 1) ex_charge = 1;
.................... else ex_charge = 0;
....................
....................
.................... /* set timer to interrupt at 1200 Hz */
.................... setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
.................... enable_interrupts(INT_TIMER1); /* enable timer1 interrupt */
.................... set_timer1(65336);
.................... ptr = 0;
....................
.................... timetag_lo = 0;
.................... timetag_hi = 0;
.................... timetag_top = 0;
.................... shift_reg = shift_reg | 0x03;
.................... shift_out(shift_reg);
000B: MOVF 2B,W
000C: MOVWF 2C
000D: CALL 004
....................
.................... for(i=0;i<200;i++) {
.................... delay_ms(500);
000E: CLRF 2D
000F: GOTO 005
.................... shift_reg = shift_reg ^ 1;
.................... shift_out(shift_reg);
0010: MOVF 2B,W
0011: MOVWF 2C
0012: CALL 004
.................... }
.................... while(1);
....................
.................... }
....................
0013: SLEEP
___________________________
This message was ported from CCS's old forum
Original Post ID: 658
Phil



Joined: 09 Sep 2003
Posts: 12

View user's profile Send private message

Re: Functions not compiling
PostPosted: Sun Oct 14, 2001 1:26 pm     Reply with quote

Well, I see that your line2 of your C file contains #include, but no file. After removing this line, I compile your code using CCS v3.050 and receive the following list. It seems to me like your compilation should work. If installing the updated version doesn't work for you, you should contact CCS about this:

CCS PCW C Compiler, Version 3.050, 12733

Filename: c:\temp\test.LST

ROM used: 169 (2\%)
Largest free fragment is 2048
RAM used: 17 (10\%) at main() level
20 (11\%) worst case
Stack: 1 locations

*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 051
0003: NOP
.................... #include <16c77.h>
.................... //////// Standard Header file for the PIC16C77 device ////////////////
.................... #device PIC16C77
.................... #list
....................
.................... //#include
....................
.................... #use delay(clock=4000000)
*
003A: MOVLW 2C
003B: MOVWF 04
003C: MOVF 00,W
003D: BTFSC 03.2
003E: GOTO 04E
003F: MOVLW 01
0040: MOVWF 78
0041: CLRF 77
0042: DECFSZ 77,F
0043: GOTO 042
0044: DECFSZ 78,F
0045: GOTO 041
0046: MOVLW 4A
0047: MOVWF 77
0048: DECFSZ 77,F
0049: GOTO 048
004A: NOP
004B: NOP
004C: DECFSZ 00,F
004D: GOTO 03F
004E: BCF 0A.3
004F: BCF 0A.4
0050: GOTO 09E (RETURN)
.................... #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
....................
.................... #define WIRE1 PIN_E0
.................... #define WIRE2 PIN_E1
.................... #define WIRE3 PIN_E2
....................
.................... unsigned byte ptr;
.................... char i;
....................
.................... byte ex_charge;
....................
....................
.................... long timetag_lo; /* 1200 Hz clock */
.................... long timetag_hi; /* 1 second clock */
.................... long timetag_top; /* upper half on 1 second clock */
.................... char *adr; /* address pointer */
.................... char shift_reg;
....................
....................
.................... char shift_out(char a) {
.................... char ip;
.................... char temp1;
.................... for(ip = 0; ip< 8;ip++) {
*
0004: CLRF 2C
0005: MOVF 2C,W
0006: SUBLW 07
0007: BTFSS 03.0
0008: GOTO 02B
.................... output_low(PIN_D5);
0009: BSF 03.5
000A: BCF 08.5
000B: BCF 03.5
000C: BCF 08.5
.................... temp1 = (a >> ip) & 0x01;
000D: MOVF 2B,W
000E: MOVWF 77
000F: MOVF 2C,W
0010: MOVWF 78
0011: BTFSC 03.2
0012: GOTO 017
0013: BCF 03.0
0014: RRF 77,F
0015: DECFSZ 78,F
0016: GOTO 013
0017: MOVF 77,W
0018: ANDLW 01
0019: MOVWF 2D
.................... if(temp1 == 1) output_high(PIN_D6);
001A: DECFSZ 2D,W
001B: GOTO 021
001C: BSF 03.5
001D: BCF 08.6
001E: BCF 03.5
001F: BSF 08.6
.................... else output_low(PIN_D6);
0020: GOTO 025
0021: BSF 03.5
0022: BCF 08.6
0023: BCF 03.5
0024: BCF 08.6
.................... output_high(PIN_D5);
0025: BSF 03.5
0026: BCF 08.5
0027: BCF 03.5
0028: BSF 08.5
.................... }
0029: INCF 2C,F
002A: GOTO 005
.................... output_low(PIN_D5);
002B: BSF 03.5
002C: BCF 08.5
002D: BCF 03.5
002E: BCF 08.5
.................... output_high(PIN_D7);
002F: BSF 03.5
0030: BCF 08.7
0031: BCF 03.5
0032: BSF 08.7
.................... output_low(PIN_D7);
0033: BSF 03.5
0034: BCF 08.7
0035: BCF 03.5
0036: BCF 08.7
.................... return(0);
0037: MOVLW 00
0038: MOVWF 78
0039: RETLW 00
.................... }
....................
.................... main()
.................... {
....................
.................... /* Configure the ports */
.................... #use fast_io(A) /* set A port IO */
*
0051: CLRF 04
0052: MOVLW 1F
0053: ANDWF 03,F
0054: MOVLW 9F
0055: MOVWF 04
0056: MOVLW 07
0057: MOVWF 00
0058: MOVLW 19
0059: BSF 03.5
005A: MOVWF 19
005B: MOVLW 26
005C: MOVWF 18
005D: MOVLW 90
005E: BCF 03.5
005F: MOVWF 18
.................... set_tris_a(0x3f);
0060: MOVLW 3F
0061: TRIS 5
.................... #use fast_io(B) /* set B port IO */
.................... set_tris_b(0x3f);
0062: TRIS 6
.................... #use fast_io(C) /* set C port IO */
.................... set_tris_c(0x92);
0063: MOVLW 92
0064: TRIS 7
.................... #use fast_io(D)
.................... set_tris_d(0x0f);
0065: MOVLW 0F
0066: TRIS 7
.................... #use fast_io(E)
.................... set_tris_e(0x07);
0067: MOVLW 07
0068: BSF 03.5
0069: MOVWF 07
.................... output_low(PIN_E0);
006A: BCF 03.5
006B: BCF 09.0
.................... output_low(PIN_E1);
006C: BCF 09.1
.................... output_low(PIN_E2);
006D: BCF 09.2
.................... adr = 0x06;
006E: MOVLW 06
006F: MOVWF 29
.................... shift_reg = 0x46;
0070: MOVLW 46
0071: MOVWF 2A
.................... shift_out(shift_reg);
0072: MOVF 2A,W
0073: MOVWF 2B
0074: CALL 004
....................
.................... if(input(PIN_B5) == 1) ex_charge = 1;
0075: MOVLW 00
0076: BTFSC 06.5
0077: MOVLW 01
0078: SUBLW 01
0079: BTFSS 03.2
007A: GOTO 07E
007B: MOVLW 01
007C: MOVWF 22
.................... else ex_charge = 0;
007D: GOTO 07F
007E: CLRF 22
....................
....................
.................... /* set timer to interrupt at 1200 Hz */
.................... setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
007F: MOVLW A5
0080: MOVWF 10
.................... enable_interrupts(INT_TIMER1); /* enable timer1 interrupt */
0081: BSF 03.5
0082: BSF 0C.0
.................... set_timer1(65336);
0083: MOVLW FF
0084: BCF 03.5
0085: MOVWF 0F
0086: MOVLW 38
0087: MOVWF 0E
.................... ptr = 0;
0088: CLRF 20
....................
.................... timetag_lo = 0;
0089: CLRF 24
008A: CLRF 23
.................... timetag_hi = 0;
008B: CLRF 26
008C: CLRF 25
.................... timetag_top = 0;
008D: CLRF 28
008E: CLRF 27
.................... shift_reg = shift_reg | 0x03;
008F: MOVLW 03
0090: IORWF 2A,F
.................... shift_out(shift_reg);
0091: MOVF 2A,W
0092: MOVWF 2B
0093: CALL 004
....................
.................... for(i=0;i<200;i++) {
0094: CLRF 21
0095: MOVF 21,W
0096: SUBLW C7
0097: BTFSS 03.0
0098: GOTO 0A7
.................... delay_ms(500);
0099: MOVLW 02
009A: MOVWF 2B
009B: MOVLW FA
009C: MOVWF 2C
009D: GOTO 03A
009E: DECFSZ 2B,F
009F: GOTO 09B
.................... shift_reg = shift_reg ^ 1;
00A0: MOVLW 01
00A1: XORWF 2A,F
.................... shift_out(shift_reg);
00A2: MOVF 2A,W
00A3: MOVWF 2B
00A4: CALL 004
.................... }
00A5: INCF 21,F
00A6: GOTO 095
.................... while(1);
00A7: GOTO 0A7
....................
.................... }
....................
00A8: SLEEP


:=:=Could you post your list file?
:=:=
:=:=Thanks,
:=:=Phil
:=:=
:=
:=
:=Here is the list file.
:=
:=Ivan
:=
:=CCS PCW C Compiler, Version 3.046, 12830
:=
:= Filename: /usr/picc/cube7.LST
:=
:= ROM used: 20 (0\%)
:= Largest free fragment is 2048
:= RAM used: 18 (10\%) at main() level
:= 21 (12\%) worst case
:= Stack: 1 locations
:=
:=*
:=0000: MOVLW 00
:=0001: MOVWF 0A
:=0002: GOTO 008
:=0003: NOP
:=.................... #include <16c77.h>
:=.................... //////// Standard Header file for the PIC16C77 device ////////////////
:=.................... #device PIC16C77
:=.................... #list
:=....................
:=.................... #include <string.h>
:=.................... ////////////////////////////////////////////////////////////////////////////
:=.................... //// (C) Copyright 1996,1997 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. ////
:=.................... ////////////////////////////////////////////////////////////////////////////
:=....................
:=.................... #include <ctype.h>
:=.................... //// (C) Copyright 1996,1997 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. ////
:=.................... ////////////////////////////////////////////////////////////////////////////
:=.................... #list
:=....................
:=....................
:=.................... /* standard template: char *strcat(char *s1, const char *s2) */
:=....................
:=.................... char strcat(char *s1, char *s2)
:=.................... {
:=.................... char *s;
:=....................
:=.................... for (s = s1; *s != '\0'; s++);
:=.................... while ((*s = *s2) != '\0')
:=.................... {
:=.................... s++;
:=.................... s2++;
:=.................... }
:=.................... return(s1);
:=.................... }
:=....................
:=.................... /***********************************************************/
:=....................
:=.................... /* standard template: char *strchr(const char *s, int c).
:=.................... Finds first occurrence of c in s1 */
:=....................
:=.................... char strchr(char *s, int c)
:=.................... {
:=.................... for (; *s != c; s++)
:=.................... if (*s == '\0')
:=.................... return(0);
:=.................... return(s);
:=.................... }
:=....................
:=.................... /* standard template: char *strrchr(const char *s, int c).
:=.................... Finds last occurrence of c in s1 */
:=....................
:=.................... char strrchr(char *s, int c)
:=.................... {
:=.................... char *p;
:=....................
:=.................... for (p = 0; ; s++)
:=.................... {
:=.................... if (*s == c)
:=.................... p = s;
:=.................... if (*s == '\0')
:=.................... return(p);
:=.................... }
:=.................... }
:=....................
:=.................... /*****************************************************************/
:=....................
:=.................... /* standard template: int strcmp(const char *s1, const char *s2).
:=.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
:=....................
:=.................... signed int strcmp(char *s1, char *s2)
:=.................... {
:=.................... for (; *s1 == *s2; s1++, s2++)
:=.................... if (*s1 == '\0')
:=.................... return(0);
:=.................... return((*s1 < *s2) ? -1: 1);
:=.................... }
:=....................
:=.................... /* standard template:
:=.................... int strncmp(const char *s1, const char *s2, size_t n).
:=.................... Compares max of n characters (not following 0) from s1 to s2;
:=.................... returns same as strcmp */
:=....................
:=.................... signed int strncmp(char *s1, char *s2, int n)
:=.................... {
:=.................... for (; n > 0; s1++, s2++, n--)
:=.................... if (*s1 != *s2)
:=.................... return((*s1 <*s2) ? -1: 1);
:=.................... else if (*s1 == '\0')
:=.................... return(0);
:=.................... return(0);
:=.................... }
:=....................
:=.................... /* standard template: size_t stricmp(const char *s1, const char *s2).
:=.................... Compares s1 to s2 ignoring case (upper vs. lower) */
:=....................
:=.................... signed int stricmp(char *s1, char *s2)
:=.................... {
:=.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));
:=.................... s1++, s2++)
:=.................... if (*s1 == '\0')
:=.................... return(0);
:=.................... return((*s1 < *s2) ? -1: 1);
:=.................... }
:=....................
:=.................... /***************************************************************/
:=....................
:=.................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved?
:=.................... Standard template: char *strcpy(char *s1, const char *s2) */
:=....................
:=.................... char strcopy(char *s1, char *s2)
:=.................... {
:=.................... char *s;
:=....................
:=.................... for (s = s1; *s2 != 0; s++, s2++)
:=.................... *s = *s2;
:=.................... return(s1);
:=.................... }
:=....................
:=.................... /* standard template:
:=.................... char *strncpy(char *s1, const char *s2, size_t n).
:=.................... Copies max of n characters (not following ending '\0')
:=.................... from s2 in s1; if s2 has less than n characters, appends 0 */
:=....................
:=.................... char strncpy(char *s1, char *s2, int n)
:=.................... {
:=.................... char *s;
:=....................
:=.................... for (s = s1; n > 0 && *s2 != '\0'; n--)
:=.................... *s++ = *s2++;
:=.................... for (; n > 0; n--)
:=.................... *s++ = '\0';
:=....................
:=.................... return(s1);
:=.................... }
:=....................
:=.................... /***************************************************************/
:=....................
:=.................... /* standard template:
:=.................... size_t strcspn(const char *s1, const char *s2).
:=.................... Computes length of max initial segment of s1 that
:=.................... consists entirely of characters NOT from s2*/
:=....................
:=.................... int strcspn(char *s1, char *s2)
:=.................... {
:=.................... char *sc1, *sc2;
:=....................
:=.................... for (sc1 = s1; *sc1 != 0; sc1++)
:=.................... for (sc2 = s2; *sc2 != 0; sc2++)
:=.................... if (*sc1 == *sc2)
:=.................... return(sc1 - s1);
:=.................... return(sc1 - s1);
:=.................... }
:=....................
:=.................... /* computes length of max initial segment of s1 consisting
:=.................... entirely of characters from s2 */
:=....................
:=.................... int strspn(char *s1, char *s2)
:=.................... {
:=.................... char *sc1, *sc2;
:=....................
:=.................... for (sc1 = s1; *sc1 != 0; sc1++)
:=.................... for (sc2 = s2; ; sc2++)
:=.................... if (*sc2 == '\0')
:=.................... return(sc1 - s1);
:=.................... else if (*sc1 == *sc2)
:=.................... break;
:=.................... return(sc1 - s1);
:=.................... }
:=....................
:=.................... /***************************************************************/
:=....................
:=.................... /* standard template: size_t strlen(const char *s).
:=.................... Computes length of s1 (preceding terminating 0) */
:=....................
:=.................... int strlen(char *s)
:=.................... {
:=.................... char *sc;
:=....................
:=.................... for (sc = s; *sc != 0; sc++);
:=.................... return(sc - s);
:=.................... }
:=....................
:=.................... /***************************************************************/
:=....................
:=.................... /* standard template: char *strlwr(char *s).
:=.................... Replaces uppercase letters by lowercase;
:=.................... returns pointer to new string s */
:=....................
:=.................... char strlwr(char *s)
:=.................... {
:=.................... char *p;
:=....................
:=.................... for (p = s; *p != '\0'; p++)
:=.................... if (*p >= 'A' && *p <='Z')
:=.................... *p += 'a' - 'A';
:=.................... return(s);
:=.................... }
:=....................
:=.................... /****************************************************************/
:=....................
:=.................... /* standard template:
:=.................... char *strpbrk(const char *s1, const char *s2).
:=.................... Locates first occurence of any character from s2 in s1;
:=.................... returns s1 if s2 is empty string */
:=....................
:=.................... char strpbrk(char *s1, char *s2)
:=.................... {
:=.................... char *sc1, *sc2;
:=....................
:=.................... for (sc1 = s1; *sc1 != 0; sc1++)
:=.................... for (sc2 = s2; *sc2 != 0; sc2++)
:=.................... if (*sc1 == *sc2)
:=.................... return(sc1);
:=.................... return(0);
:=.................... }
:=....................
:=.................... /****************************************************************/
:=....................
:=.................... /* standard template:
:=.................... char *strstr(const char *s1, const char *s2);
:=.................... Locates first occurence of character sequence s2 in s1;
:=.................... returns 0 if s2 is empty string */
:=....................
:=.................... char strstr(char *s1, char *s2)
:=.................... {
:=.................... char *sc1, *sc2;
:=....................
:=.................... if (*s2 == 0)
:=.................... return(s1);
:=.................... for (; s1 = strchr(s1, *s2); s1++)
:=.................... {
:=.................... for (sc1 = s1, sc2 = s2; ; sc1++, sc2++)
:=.................... if (*sc2 == 0)
:=.................... return(s1);
:=.................... else if (*sc1 != *sc2)
:=.................... break;
:=.................... }
:=.................... return(0);
:=.................... }
:=....................
:=.................... /************************************************************/
:=....................
:=.................... /* standard template: char *strtok(char *s1, const char *s2).
:=....................
:=.................... Finds next token in s1 delimited by a character from separator
:=.................... string s2 (which can be different from call to call). First call
:=.................... starts at beginning of s1 searching for first character NOT
:=.................... contained in s2; returns 0 if none is found.
:=.................... If one is found, it is the start of first token (return value).
:=.................... Function then searches from there for a character contained in s2.
:=.................... If none is found, current token extends to end of s1, and subsequent
:=.................... searches for a token will return 0. If one is found, it is
:=.................... overwritten by '\0', which terminates current token. Function saves
:=.................... pointer to following character from which next search will start.
:=.................... Each subsequent call, with 0 as first argument, starts searching
:=.................... from saved pointer */
:=....................
:=.................... char strtok(char *s1, char *s2)
:=.................... {
:=.................... char *beg, *end;
:=.................... static char *save;
:=....................
:=.................... beg = (s1)? s1: save;
:=.................... beg += strspn(beg, s2);
:=.................... if (*beg == '\0')
:=.................... {
:=.................... *save = ' ';
:=.................... return(0);
:=.................... }
:=.................... end = strpbrk(beg, s2);
:=.................... if (*end != '\0')
:=.................... {
:=.................... *end = '\0';
:=.................... end++;
:=.................... }
:=.................... save = end;
:=.................... return(beg);
:=.................... }
:=....................
:=....................
:=....................
:=.................... #use delay(clock=4000000)
:=*
:=0005: BCF 0A.3
:=0006: BCF 0A.4
:=0007: GOTO 010 (RETURN)
:=.................... #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
:=....................
:=.................... #define WIRE1 PIN_E0
:=.................... #define WIRE2 PIN_E1
:=.................... #define WIRE3 PIN_E2
:=....................
:=.................... unsigned byte ptr;
:=.................... char i;
:=....................
:=.................... byte ex_charge;
:=....................
:=....................
:=.................... long timetag_lo; /* 1200 Hz clock */
:=.................... long timetag_hi; /* 1 second clock */
:=.................... long timetag_top; /* upper half on 1 second clock */
:=.................... char *adr; /* address pointer */
:=.................... char shift_reg;
:=....................
:=....................
:=.................... char shift_out(char a) {
:=.................... char ip;
:=.................... char temp1;
:=.................... for(ip = 0; ip< 8;ip++) {
:=.................... output_low(PIN_D5);
:=.................... temp1 = (a >> ip) & 0x01;
:=.................... if(temp1 == 1) output_high(PIN_D6);
:=.................... else output_low(PIN_D6);
:=.................... output_high(PIN_D5);
:=.................... }
:=.................... output_low(PIN_D5);
:=.................... output_high(PIN_D7);
:=.................... output_low(PIN_D7);
:=.................... return(0);
:=*
:=0004: RETLW 00
:=.................... }
:=....................
:=.................... main()
:=.................... {
:=....................
:=.................... /* Configure the ports */
:=.................... #use fast_io(A) /* set A port IO */
:=.................... set_tris_a(0x3f);
:=.................... #use fast_io(B) /* set B port IO */
:=.................... set_tris_b(0x3f);
:=.................... #use fast_io(C) /* set C port IO */
:=.................... set_tris_c(0x92);
:=.................... #use fast_io(D)
:=.................... set_tris_d(0x0f);
:=.................... #use fast_io(E)
:=.................... set_tris_e(0x07);
:=.................... output_low(PIN_E0);
:=.................... output_low(PIN_E1);
:=.................... output_low(PIN_E2);
:=.................... adr = 0x06;
:=.................... shift_reg = 0x46;
:=.................... shift_out(shift_reg);
:=*
:=0008: MOVF 2B,W
:=0009: MOVWF 2C
:=000A: CALL 004
:=....................
:=.................... if(input(PIN_B5) == 1) ex_charge = 1;
:=.................... else ex_charge = 0;
:=....................
:=....................
:=.................... /* set timer to interrupt at 1200 Hz */
:=.................... setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
:=.................... enable_interrupts(INT_TIMER1); /* enable timer1 interrupt */
:=.................... set_timer1(65336);
:=.................... ptr = 0;
:=....................
:=.................... timetag_lo = 0;
:=.................... timetag_hi = 0;
:=.................... timetag_top = 0;
:=.................... shift_reg = shift_reg | 0x03;
:=.................... shift_out(shift_reg);
:=000B: MOVF 2B,W
:=000C: MOVWF 2C
:=000D: CALL 004
:=....................
:=.................... for(i=0;i<200;i++) {
:=.................... delay_ms(500);
:=000E: CLRF 2D
:=000F: GOTO 005
:=.................... shift_reg = shift_reg ^ 1;
:=.................... shift_out(shift_reg);
:=0010: MOVF 2B,W
:=0011: MOVWF 2C
:=0012: CALL 004
:=.................... }
:=.................... while(1);
:=....................
:=.................... }
:=....................
:=0013: SLEEP
___________________________
This message was ported from CCS's old forum
Original Post ID: 659
Phil



Joined: 09 Sep 2003
Posts: 12

View user's profile Send private message

Re:Also note the following bug
PostPosted: Sun Oct 14, 2001 1:32 pm     Reply with quote

<font face="Courier New" size=-1>Also note 3.050 contains a bug resulting in the following:

.................... #use fast_io(C) /* set C port IO */
.................... set_tris_c(0x92);
0063: MOVLW 92
0064: TRIS 7
.................... #use fast_io(D)
.................... set_tris_d(0x0f);
0065: MOVLW 0F
0066: TRIS 7

As you see tris_d (and tris_e) point to the incorrect register.

Phil
:=Well, I see that your line2 of your C file contains #include, but no file. After removing this line, I compile your code using CCS v3.050 and receive the following list. It seems to me like your compilation should work. If installing the updated version doesn't work for you, you should contact CCS about this:
:=
:=CCS PCW C Compiler, Version 3.050, 12733
:=
:= Filename: c:\temp\test.LST
:=
:= ROM used: 169 (2\%)
:= Largest free fragment is 2048
:= RAM used: 17 (10\%) at main() level
:= 20 (11\%) worst case
:= Stack: 1 locations
:=
:=*
:=0000: MOVLW 00
:=0001: MOVWF 0A
:=0002: GOTO 051
:=0003: NOP
:=.................... #include <16c77.h>
:=.................... //////// Standard Header file for the PIC16C77 device ////////////////
:=.................... #device PIC16C77
:=.................... #list
:=....................
:=.................... //#include
:=....................
:=.................... #use delay(clock=4000000)
:=*
:=003A: MOVLW 2C
:=003B: MOVWF 04
:=003C: MOVF 00,W
:=003D: BTFSC 03.2
:=003E: GOTO 04E
:=003F: MOVLW 01
:=0040: MOVWF 78
:=0041: CLRF 77
:=0042: DECFSZ 77,F
:=0043: GOTO 042
:=0044: DECFSZ 78,F
:=0045: GOTO 041
:=0046: MOVLW 4A
:=0047: MOVWF 77
:=0048: DECFSZ 77,F
:=0049: GOTO 048
:=004A: NOP
:=004B: NOP
:=004C: DECFSZ 00,F
:=004D: GOTO 03F
:=004E: BCF 0A.3
:=004F: BCF 0A.4
:=0050: GOTO 09E (RETURN)
:=.................... #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
:=....................
:=.................... #define WIRE1 PIN_E0
:=.................... #define WIRE2 PIN_E1
:=.................... #define WIRE3 PIN_E2
:=....................
:=.................... unsigned byte ptr;
:=.................... char i;
:=....................
:=.................... byte ex_charge;
:=....................
:=....................
:=.................... long timetag_lo; /* 1200 Hz clock */
:=.................... long timetag_hi; /* 1 second clock */
:=.................... long timetag_top; /* upper half on 1 second clock */
:=.................... char *adr; /* address pointer */
:=.................... char shift_reg;
:=....................
:=....................
:=.................... char shift_out(char a) {
:=.................... char ip;
:=.................... char temp1;
:=.................... for(ip = 0; ip< 8;ip++) {
:=*
:=0004: CLRF 2C
:=0005: MOVF 2C,W
:=0006: SUBLW 07
:=0007: BTFSS 03.0
:=0008: GOTO 02B
:=.................... output_low(PIN_D5);
:=0009: BSF 03.5
:=000A: BCF 08.5
:=000B: BCF 03.5
:=000C: BCF 08.5
:=.................... temp1 = (a >> ip) & 0x01;
:=000D: MOVF 2B,W
:=000E: MOVWF 77
:=000F: MOVF 2C,W
:=0010: MOVWF 78
:=0011: BTFSC 03.2
:=0012: GOTO 017
:=0013: BCF 03.0
:=0014: RRF 77,F
:=0015: DECFSZ 78,F
:=0016: GOTO 013
:=0017: MOVF 77,W
:=0018: ANDLW 01
:=0019: MOVWF 2D
:=.................... if(temp1 == 1) output_high(PIN_D6);
:=001A: DECFSZ 2D,W
:=001B: GOTO 021
:=001C: BSF 03.5
:=001D: BCF 08.6
:=001E: BCF 03.5
:=001F: BSF 08.6
:=.................... else output_low(PIN_D6);
:=0020: GOTO 025
:=0021: BSF 03.5
:=0022: BCF 08.6
:=0023: BCF 03.5
:=0024: BCF 08.6
:=.................... output_high(PIN_D5);
:=0025: BSF 03.5
:=0026: BCF 08.5
:=0027: BCF 03.5
:=0028: BSF 08.5
:=.................... }
:=0029: INCF 2C,F
:=002A: GOTO 005
:=.................... output_low(PIN_D5);
:=002B: BSF 03.5
:=002C: BCF 08.5
:=002D: BCF 03.5
:=002E: BCF 08.5
:=.................... output_high(PIN_D7);
:=002F: BSF 03.5
:=0030: BCF 08.7
:=0031: BCF 03.5
:=0032: BSF 08.7
:=.................... output_low(PIN_D7);
:=0033: BSF 03.5
:=0034: BCF 08.7
:=0035: BCF 03.5
:=0036: BCF 08.7
:=.................... return(0);
:=0037: MOVLW 00
:=0038: MOVWF 78
:=0039: RETLW 00
:=.................... }
:=....................
:=.................... main()
:=.................... {
:=....................
:=.................... /* Configure the ports */
:=.................... #use fast_io(A) /* set A port IO */
:=*
:=0051: CLRF 04
:=0052: MOVLW 1F
:=0053: ANDWF 03,F
:=0054: MOVLW 9F
:=0055: MOVWF 04
:=0056: MOVLW 07
:=0057: MOVWF 00
:=0058: MOVLW 19
:=0059: BSF 03.5
:=005A: MOVWF 19
:=005B: MOVLW 26
:=005C: MOVWF 18
:=005D: MOVLW 90
:=005E: BCF 03.5
:=005F: MOVWF 18
:=.................... set_tris_a(0x3f);
:=0060: MOVLW 3F
:=0061: TRIS 5
:=.................... #use fast_io(B) /* set B port IO */
:=.................... set_tris_b(0x3f);
:=0062: TRIS 6
:=.................... #use fast_io(C) /* set C port IO */
:=.................... set_tris_c(0x92);
:=0063: MOVLW 92
:=0064: TRIS 7
:=.................... #use fast_io(D)
:=.................... set_tris_d(0x0f);
:=0065: MOVLW 0F
:=0066: TRIS 7
:=.................... #use fast_io(E)
:=.................... set_tris_e(0x07);
:=0067: MOVLW 07
:=0068: BSF 03.5
:=0069: MOVWF 07
:=.................... output_low(PIN_E0);
:=006A: BCF 03.5
:=006B: BCF 09.0
:=.................... output_low(PIN_E1);
:=006C: BCF 09.1
:=.................... output_low(PIN_E2);
:=006D: BCF 09.2
:=.................... adr = 0x06;
:=006E: MOVLW 06
:=006F: MOVWF 29
:=.................... shift_reg = 0x46;
:=0070: MOVLW 46
:=0071: MOVWF 2A
:=.................... shift_out(shift_reg);
:=0072: MOVF 2A,W
:=0073: MOVWF 2B
:=0074: CALL 004
:=....................
:=.................... if(input(PIN_B5) == 1) ex_charge = 1;
:=0075: MOVLW 00
:=0076: BTFSC 06.5
:=0077: MOVLW 01
:=0078: SUBLW 01
:=0079: BTFSS 03.2
:=007A: GOTO 07E
:=007B: MOVLW 01
:=007C: MOVWF 22
:=.................... else ex_charge = 0;
:=007D: GOTO 07F
:=007E: CLRF 22
:=....................
:=....................
:=.................... /* set timer to interrupt at 1200 Hz */
:=.................... setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
:=007F: MOVLW A5
:=0080: MOVWF 10
:=.................... enable_interrupts(INT_TIMER1); /* enable timer1 interrupt */
:=0081: BSF 03.5
:=0082: BSF 0C.0
:=.................... set_timer1(65336);
:=0083: MOVLW FF
:=0084: BCF 03.5
:=0085: MOVWF 0F
:=0086: MOVLW 38
:=0087: MOVWF 0E
:=.................... ptr = 0;
:=0088: CLRF 20
:=....................
:=.................... timetag_lo = 0;
:=0089: CLRF 24
:=008A: CLRF 23
:=.................... timetag_hi = 0;
:=008B: CLRF 26
:=008C: CLRF 25
:=.................... timetag_top = 0;
:=008D: CLRF 28
:=008E: CLRF 27
:=.................... shift_reg = shift_reg | 0x03;
:=008F: MOVLW 03
:=0090: IORWF 2A,F
:=.................... shift_out(shift_reg);
:=0091: MOVF 2A,W
:=0092: MOVWF 2B
:=0093: CALL 004
:=....................
:=.................... for(i=0;i<200;i++) {
:=0094: CLRF 21
:=0095: MOVF 21,W
:=0096: SUBLW C7
:=0097: BTFSS 03.0
:=0098: GOTO 0A7
:=.................... delay_ms(500);
:=0099: MOVLW 02
:=009A: MOVWF 2B
:=009B: MOVLW FA
:=009C: MOVWF 2C
:=009D: GOTO 03A
:=009E: DECFSZ 2B,F
:=009F: GOTO 09B
:=.................... shift_reg = shift_reg ^ 1;
:=00A0: MOVLW 01
:=00A1: XORWF 2A,F
:=.................... shift_out(shift_reg);
:=00A2: MOVF 2A,W
:=00A3: MOVWF 2B
:=00A4: CALL 004
:=.................... }
:=00A5: INCF 21,F
:=00A6: GOTO 095
:=.................... while(1);
:=00A7: GOTO 0A7
:=....................
:=.................... }
:=....................
:=00A8: SLEEP
:=
:=
:=:=:=Could you post your list file?
:=:=:=
:=:=:=Thanks,
:=:=:=Phil
:=:=:=
:=:=
:=:=
:=:=Here is the list file.
:=:=
:=:=Ivan
:=:=
:=:=CCS PCW C Compiler, Version 3.046, 12830
:=:=
:=:= Filename: /usr/picc/cube7.LST
:=:=
:=:= ROM used: 20 (0\%)
:=:= Largest free fragment is 2048
:=:= RAM used: 18 (10\%) at main() level
:=:= 21 (12\%) worst case
:=:= Stack: 1 locations
:=:=
:=:=*
:=:=0000: MOVLW 00
:=:=0001: MOVWF 0A
:=:=0002: GOTO 008
:=:=0003: NOP
:=:=.................... #include <16c77.h>
:=:=.................... //////// Standard Header file for the PIC16C77 device ////////////////
:=:=.................... #device PIC16C77
:=:=.................... #list
:=:=....................
:=:=.................... #include <string.h>
:=:=.................... ////////////////////////////////////////////////////////////////////////////
:=:=.................... //// (C) Copyright 1996,1997 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. ////
:=:=.................... ////////////////////////////////////////////////////////////////////////////
:=:=....................
:=:=.................... #include <ctype.h>
:=:=.................... //// (C) Copyright 1996,1997 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. ////
:=:=.................... ////////////////////////////////////////////////////////////////////////////
:=:=.................... #list
:=:=....................
:=:=....................
:=:=.................... /* standard template: char *strcat(char *s1, const char *s2) */
:=:=....................
:=:=.................... char strcat(char *s1, char *s2)
:=:=.................... {
:=:=.................... char *s;
:=:=....................
:=:=.................... for (s = s1; *s != '\0'; s++);
:=:=.................... while ((*s = *s2) != '\0')
:=:=.................... {
:=:=.................... s++;
:=:=.................... s2++;
:=:=.................... }
:=:=.................... return(s1);
:=:=.................... }
:=:=....................
:=:=.................... /***********************************************************/
:=:=....................
:=:=.................... /* standard template: char *strchr(const char *s, int c).
:=:=.................... Finds first occurrence of c in s1 */
:=:=....................
:=:=.................... char strchr(char *s, int c)
:=:=.................... {
:=:=.................... for (; *s != c; s++)
:=:=.................... if (*s == '\0')
:=:=.................... return(0);
:=:=.................... return(s);
:=:=.................... }
:=:=....................
:=:=.................... /* standard template: char *strrchr(const char *s, int c).
:=:=.................... Finds last occurrence of c in s1 */
:=:=....................
:=:=.................... char strrchr(char *s, int c)
:=:=.................... {
:=:=.................... char *p;
:=:=....................
:=:=.................... for (p = 0; ; s++)
:=:=.................... {
:=:=.................... if (*s == c)
:=:=.................... p = s;
:=:=.................... if (*s == '\0')
:=:=.................... return(p);
:=:=.................... }
:=:=.................... }
:=:=....................
:=:=.................... /*****************************************************************/
:=:=....................
:=:=.................... /* standard template: int strcmp(const char *s1, const char *s2).
:=:=.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
:=:=....................
:=:=.................... signed int strcmp(char *s1, char *s2)
:=:=.................... {
:=:=.................... for (; *s1 == *s2; s1++, s2++)
:=:=.................... if (*s1 == '\0')
:=:=.................... return(0);
:=:=.................... return((*s1 < *s2) ? -1: 1);
:=:=.................... }
:=:=....................
:=:=.................... /* standard template:
:=:=.................... int strncmp(const char *s1, const char *s2, size_t n).
:=:=.................... Compares max of n characters (not following 0) from s1 to s2;
:=:=.................... returns same as strcmp */
:=:=....................
:=:=.................... signed int strncmp(char *s1, char *s2, int n)
:=:=.................... {
:=:=.................... for (; n > 0; s1++, s2++, n--)
:=:=.................... if (*s1 != *s2)
:=:=.................... return((*s1 <*s2) ? -1: 1);
:=:=.................... else if (*s1 == '\0')
:=:=.................... return(0);
:=:=.................... return(0);
:=:=.................... }
:=:=....................
:=:=.................... /* standard template: size_t stricmp(const char *s1, const char *s2).
:=:=.................... Compares s1 to s2 ignoring case (upper vs. lower) */
:=:=....................
:=:=.................... signed int stricmp(char *s1, char *s2)
:=:=.................... {
:=:=.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));
:=:=.................... s1++, s2++)
:=:=.................... if (*s1 == '\0')
:=:=.................... return(0);
:=:=.................... return((*s1 < *s2) ? -1: 1);
:=:=.................... }
:=:=....................
:=:=.................... /***************************************************************/
:=:=....................
:=:=.................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved?
:=:=.................... Standard template: char *strcpy(char *s1, const char *s2) */
:=:=....................
:=:=.................... char strcopy(char *s1, char *s2)
:=:=.................... {
:=:=.................... char *s;
:=:=....................
:=:=.................... for (s = s1; *s2 != 0; s++, s2++)
:=:=.................... *s = *s2;
:=:=.................... return(s1);
:=:=.................... }
:=:=....................
:=:=.................... /* standard template:
:=:=.................... char *strncpy(char *s1, const char *s2, size_t n).
:=:=.................... Copies max of n characters (not following ending '\0')
:=:=.................... from s2 in s1; if s2 has less than n characters, appends 0 */
:=:=....................
:=:=.................... char strncpy(char *s1, char *s2, int n)
:=:=.................... {
:=:=.................... char *s;
:=:=....................
:=:=.................... for (s = s1; n > 0 && *s2 != '\0'; n--)
:=:=.................... *s++ = *s2++;
:=:=.................... for (; n > 0; n--)
:=:=.................... *s++ = '\0';
:=:=....................
:=:=.................... return(s1);
:=:=.................... }
:=:=....................
:=:=.................... /***************************************************************/
:=:=....................
:=:=.................... /* standard template:
:=:=.................... size_t strcspn(const char *s1, const char *s2).
:=:=.................... Computes length of max initial segment of s1 that
:=:=.................... consists entirely of characters NOT from s2*/
:=:=....................
:=:=.................... int strcspn(char *s1, char *s2)
:=:=.................... {
:=:=.................... char *sc1, *sc2;
:=:=....................
:=:=.................... for (sc1 = s1; *sc1 != 0; sc1++)
:=:=.................... for (sc2 = s2; *sc2 != 0; sc2++)
:=:=.................... if (*sc1 == *sc2)
:=:=.................... return(sc1 - s1);
:=:=.................... return(sc1 - s1);
:=:=.................... }
:=:=....................
:=:=.................... /* computes length of max initial segment of s1 consisting
:=:=.................... entirely of characters from s2 */
:=:=....................
:=:=.................... int strspn(char *s1, char *s2)
:=:=.................... {
:=:=.................... char *sc1, *sc2;
:=:=....................
:=:=.................... for (sc1 = s1; *sc1 != 0; sc1++)
:=:=.................... for (sc2 = s2; ; sc2++)
:=:=.................... if (*sc2 == '\0')
:=:=.................... return(sc1 - s1);
:=:=.................... else if (*sc1 == *sc2)
:=:=.................... break;
:=:=.................... return(sc1 - s1);
:=:=.................... }
:=:=....................
:=:=.................... /***************************************************************/
:=:=....................
:=:=.................... /* standard template: size_t strlen(const char *s).
:=:=.................... Computes length of s1 (preceding terminating 0) */
:=:=....................
:=:=.................... int strlen(char *s)
:=:=.................... {
:=:=.................... char *sc;
:=:=....................
:=:=.................... for (sc = s; *sc != 0; sc++);
:=:=.................... return(sc - s);
:=:=.................... }
:=:=....................
:=:=.................... /***************************************************************/
:=:=....................
:=:=.................... /* standard template: char *strlwr(char *s).
:=:=.................... Replaces uppercase letters by lowercase;
:=:=.................... returns pointer to new string s */
:=:=....................
:=:=.................... char strlwr(char *s)
:=:=.................... {
:=:=.................... char *p;
:=:=....................
:=:=.................... for (p = s; *p != '\0'; p++)
:=:=.................... if (*p >= 'A' && *p <='Z')
:=:=.................... *p += 'a' - 'A';
:=:=.................... return(s);
:=:=.................... }
:=:=....................
:=:=.................... /****************************************************************/
:=:=....................
:=:=.................... /* standard template:
:=:=.................... char *strpbrk(const char *s1, const char *s2).
:=:=.................... Locates first occurence of any character from s2 in s1;
:=:=.................... returns s1 if s2 is empty string */
:=:=....................
:=:=.................... char strpbrk(char *s1, char *s2)
:=:=.................... {
:=:=.................... char *sc1, *sc2;
:=:=....................
:=:=.................... for (sc1 = s1; *sc1 != 0; sc1++)
:=:=.................... for (sc2 = s2; *sc2 != 0; sc2++)
:=:=.................... if (*sc1 == *sc2)
:=:=.................... return(sc1);
:=:=.................... return(0);
:=:=.................... }
:=:=....................
:=:=.................... /****************************************************************/
:=:=....................
:=:=.................... /* standard template:
:=:=.................... char *strstr(const char *s1, const char *s2);
:=:=.................... Locates first occurence of character sequence s2 in s1;
:=:=.................... returns 0 if s2 is empty string */
:=:=....................
:=:=.................... char strstr(char *s1, char *s2)
:=:=.................... {
:=:=.................... char *sc1, *sc2;
:=:=....................
:=:=.................... if (*s2 == 0)
:=:=.................... return(s1);
:=:=.................... for (; s1 = strchr(s1, *s2); s1++)
:=:=.................... {
:=:=.................... for (sc1 = s1, sc2 = s2; ; sc1++, sc2++)
:=:=.................... if (*sc2 == 0)
:=:=.................... return(s1);
:=:=.................... else if (*sc1 != *sc2)
:=:=.................... break;
:=:=.................... }
:=:=.................... return(0);
:=:=.................... }
:=:=....................
:=:=.................... /************************************************************/
:=:=....................
:=:=.................... /* standard template: char *strtok(char *s1, const char *s2).
:=:=....................
:=:=.................... Finds next token in s1 delimited by a character from separator
:=:=.................... string s2 (which can be different from call to call). First call
:=:=.................... starts at beginning of s1 searching for first character NOT
:=:=.................... contained in s2; returns 0 if none is found.
:=:=.................... If one is found, it is the start of first token (return value).
:=:=.................... Function then searches from there for a character contained in s2.
:=:=.................... If none is found, current token extends to end of s1, and subsequent
:=:=.................... searches for a token will return 0. If one is found, it is
:=:=.................... overwritten by '\0', which terminates current token. Function saves
:=:=.................... pointer to following character from which next search will start.
:=:=.................... Each subsequent call, with 0 as first argument, starts searching
:=:=.................... from saved pointer */
:=:=....................
:=:=.................... char strtok(char *s1, char *s2)
:=:=.................... {
:=:=.................... char *beg, *end;
:=:=.................... static char *save;
:=:=....................
:=:=.................... beg = (s1)? s1: save;
:=:=.................... beg += strspn(beg, s2);
:=:=.................... if (*beg == '\0')
:=:=.................... {
:=:=.................... *save = ' ';
:=:=.................... return(0);
:=:=.................... }
:=:=.................... end = strpbrk(beg, s2);
:=:=.................... if (*end != '\0')
:=:=.................... {
:=:=.................... *end = '\0';
:=:=.................... end++;
:=:=.................... }
:=:=.................... save = end;
:=:=.................... return(beg);
:=:=.................... }
:=:=....................
:=:=....................
:=:=....................
:=:=.................... #use delay(clock=4000000)
:=:=*
:=:=0005: BCF 0A.3
:=:=0006: BCF 0A.4
:=:=0007: GOTO 010 (RETURN)
:=:=.................... #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
:=:=....................
:=:=.................... #define WIRE1 PIN_E0
:=:=.................... #define WIRE2 PIN_E1
:=:=.................... #define WIRE3 PIN_E2
:=:=....................
:=:=.................... unsigned byte ptr;
:=:=.................... char i;
:=:=....................
:=:=.................... byte ex_charge;
:=:=....................
:=:=....................
:=:=.................... long timetag_lo; /* 1200 Hz clock */
:=:=.................... long timetag_hi; /* 1 second clock */
:=:=.................... long timetag_top; /* upper half on 1 second clock */
:=:=.................... char *adr; /* address pointer */
:=:=.................... char shift_reg;
:=:=....................
:=:=....................
:=:=.................... char shift_out(char a) {
:=:=.................... char ip;
:=:=.................... char temp1;
:=:=.................... for(ip = 0; ip< 8;ip++) {
:=:=.................... output_low(PIN_D5);
:=:=.................... temp1 = (a >> ip) & 0x01;
:=:=.................... if(temp1 == 1) output_high(PIN_D6);
:=:=.................... else output_low(PIN_D6);
:=:=.................... output_high(PIN_D5);
:=:=.................... }
:=:=.................... output_low(PIN_D5);
:=:=.................... output_high(PIN_D7);
:=:=.................... output_low(PIN_D7);
:=:=.................... return(0);
:=:=*
:=:=0004: RETLW 00
:=:=.................... }
:=:=....................
:=:=.................... main()
:=:=.................... {
:=:=....................
:=:=.................... /* Configure the ports */
:=:=.................... #use fast_io(A) /* set A port IO */
:=:=.................... set_tris_a(0x3f);
:=:=.................... #use fast_io(B) /* set B port IO */
:=:=.................... set_tris_b(0x3f);
:=:=.................... #use fast_io(C) /* set C port IO */
:=:=.................... set_tris_c(0x92);
:=:=.................... #use fast_io(D)
:=:=.................... set_tris_d(0x0f);
:=:=.................... #use fast_io(E)
:=:=.................... set_tris_e(0x07);
:=:=.................... output_low(PIN_E0);
:=:=.................... output_low(PIN_E1);
:=:=.................... output_low(PIN_E2);
:=:=.................... adr = 0x06;
:=:=.................... shift_reg = 0x46;
:=:=.................... shift_out(shift_reg);
:=:=*
:=:=0008: MOVF 2B,W
:=:=0009: MOVWF 2C
:=:=000A: CALL 004
:=:=....................
:=:=.................... if(input(PIN_B5) == 1) ex_charge = 1;
:=:=.................... else ex_charge = 0;
:=:=....................
:=:=....................
:=:=.................... /* set timer to interrupt at 1200 Hz */
:=:=.................... setup_timer_1(T1_INTERNAL | T1_DIV_BY_4);
:=:=.................... enable_interrupts(INT_TIMER1); /* enable timer1 interrupt */
:=:=.................... set_timer1(65336);
:=:=.................... ptr = 0;
:=:=....................
:=:=.................... timetag_lo = 0;
:=:=.................... timetag_hi = 0;
:=:=.................... timetag_top = 0;
:=:=.................... shift_reg = shift_reg | 0x03;
:=:=.................... shift_out(shift_reg);
:=:=000B: MOVF 2B,W
:=:=000C: MOVWF 2C
:=:=000D: CALL 004
:=:=....................
:=:=.................... for(i=0;i<200;i++) {
:=:=.................... delay_ms(500);
:=:=000E: CLRF 2D
:=:=000F: GOTO 005
:=:=.................... shift_reg = shift_reg ^ 1;
:=:=.................... shift_out(shift_reg);
:=:=0010: MOVF 2B,W
:=:=0011: MOVWF 2C
:=:=0012: CALL 004
:=:=.................... }
:=:=.................... while(1);
:=:=....................
:=:=.................... }
:=:=....................
:=:=0013: SLEEP ___________________________
This message was ported from CCS's old forum
Original Post ID: 660
Ivan
Guest







Re: Functions not compiling
PostPosted: Sun Oct 14, 2001 1:43 pm     Reply with quote

That include statement was to by #include <string.h> It didn't copy for some reason. I took that out and got the same results when I compiled. Are there any flags I should be setting for the compiler?

Ivan


:=Well, I see that your line2 of your C file contains #include, but no file. After removing this line, I compile your code using CCS v3.050 and receive the following list. It seems to me like your compilation should work. If installing the updated version doesn't work for you, you should contact CCS about this:
___________________________
This message was ported from CCS's old forum
Original Post ID: 661
Phil



Joined: 09 Sep 2003
Posts: 12

View user's profile Send private message

Re: Functions not compiling
PostPosted: Sun Oct 14, 2001 9:58 pm     Reply with quote

No flags. It really should be compiling properly. My only advice would be to re-install your compiler, ensure your using the correct compiler (PCM), and try to re-compile. If that doesn't work, I think the support@ccsinfo.com is your only solution.

Phil

:=That include statement was to by #include <string.h> It didn't copy for some reason. I took that out and got the same results when I compiled. Are there any flags I should be setting for the compiler?
:=
:=Ivan
:=
:=
:=:=Well, I see that your line2 of your C file contains #include, but no file. After removing this line, I compile your code using CCS v3.050 and receive the following list. It seems to me like your compilation should work. If installing the updated version doesn't work for you, you should contact CCS about this:
___________________________
This message was ported from CCS's old forum
Original Post ID: 664
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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