Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
#include<stdio.h>#include<p24HJ32GP202.h>#include <delays.h>void main(void){int count=0;TRISB = 0x00;PORTB = 0x00; while(1) { for(count=0;count<50;count++) { //far counter-clockwise PORTB = 0x01; Delay1KTCYx(10); PORTB = 0x00; Delay1KTCYx(90); } //middle for(count=0;count<50;count++) { PORTB = 0x01; Delay1KTCYx(7); Delay100TCYx(5); PORTB = 0x00; Delay1KTCYx(92); Delay100TCYx(5); } for(count=0;count<50;count++) { //far counter-clockwise PORTB = 0x01; Delay1KTCYx(5); //Delay100TCYx(5); PORTB = 0x00; Delay1KTCYx(95); //Delay100TCYx(5); } ;}}
//Delay100TCYx(5); } ;}}
#ifndef __DELAYS_H#define __DELAYS_H/* PIC 17Cxxx and 18Cxxx cycle-count delay routines. * * Functions: * Delay1TCY() * Delay10TCY() // 17Cxx only * Delay10TCYx() * Delay100TCYx() * Delay1KTCYx() * Delay10KTCYx() *//* Delay of exactly 1 Tcy */#define Delay1TCY() Nop() #if __18CXX#define PARAM_SCLASS auto#else#define PARAM_SCLASS static#endif/* Delay of exactly 10 Tcy */#if __18CXX#define Delay10TCY() Delay10TCYx(1)#else /* 17CXX */far void Delay10TCY(void);#endif/* Delay10TCYx * Delay multiples of 10 Tcy * Passing 0 (zero) results in a delay of 2560 cycles. * The 18Cxxx version of this function supports the full range [0,255] * The 17Cxxx version supports [2,255] and 0. */#if __18CXXvoid Delay10TCYx(PARAM_SCLASS unsigned char);#else /* 17CXX */far void Delay10TCYx(PARAM_SCLASS unsigned char);#endif/* Delay100TCYx * Delay multiples of 100 Tcy * Passing 0 (zero) results in a delay of 25,600 cycles. * The full range of [0,255] is supported. */#if __18CXXvoid Delay100TCYx(PARAM_SCLASS unsigned char);#else /* 17CXX */far void Delay100TCYx(PARAM_SCLASS unsigned char);#endif/* Delay1KTCYx * Delay multiples of 1000 Tcy * Passing 0 (zero) results in a delay of 256,000 cycles. * The full range of [0,255] is supported. */#if __18CXXvoid Delay1KTCYx(PARAM_SCLASS unsigned char);#else /* 17CXX */far void Delay1KTCYx(PARAM_SCLASS unsigned char);#endif/* Delay10KTCYx * Delay multiples of 10,000 Tcy * Passing 0 (zero) results in a delay of 2,560,000 cycles. * The full range of [0,255] is supported. */#if __18CXXvoid Delay10KTCYx(PARAM_SCLASS unsigned char);#else /* 17CXX */far void Delay10KTCYx(PARAM_SCLASS unsigned char);#endif#endif
Is the "far" keyword supported by your compiler?
You could try just deleting each occurrence of the word "far" from that header file.
Executing: "C:\Program Files (x86)\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=24HJ32GP202 -x c -c "single_servo.c" -o"single_servo.o" -g -WallIn file included from single_servo.c:3:c:/program files (x86)/microchip/mplabc30/v3.25/bin/bin/../../support/PIC24H/h/delays.h:40: error: storage class specified for parameter 'type name'c:/program files (x86)/microchip/mplabc30/v3.25/bin/bin/../../support/PIC24H/h/delays.h:51: error: storage class specified for parameter 'type name'c:/program files (x86)/microchip/mplabc30/v3.25/bin/bin/../../support/PIC24H/h/delays.h:62: error: storage class specified for parameter 'type name'c:/program files (x86)/microchip/mplabc30/v3.25/bin/bin/../../support/PIC24H/h/delays.h:73: error: storage class specified for parameter 'type name'single_servo.c:6: warning: return type of 'main' is not 'int'single_servo.c:43:2: warning: no newline at end of fileHalting build on first failure as requested.BUILD FAILED: Thu Jul 07 17:49:24 2011
far void Delay10TCY(void);
Did you try deleting the PARAM_SCLASS?
undefined reference to `Delay1KTCYx'
#ifndef __DELAYS_H#define __DELAYS_H/* PIC 17Cxxx and 18Cxxx cycle-count delay routines. * * Functions: * Delay1TCY() * Delay10TCY() // 17Cxx only * Delay10TCYx() * Delay100TCYx() * Delay1KTCYx() * Delay10KTCYx() *//* Delay of exactly 1 Tcy */#define Delay1TCY() Nop() #if __18CXX#define auto#else#define static#endif/* Delay of exactly 10 Tcy */#if __18CXX#define Delay10TCY() Delay10TCYx(1)#else /* 17CXX */void Delay10TCY(void);#endif/* Delay10TCYx * Delay multiples of 10 Tcy * Passing 0 (zero) results in a delay of 2560 cycles. * The 18Cxxx version of this function supports the full range [0,255] * The 17Cxxx version supports [2,255] and 0. */#if __18CXXvoid Delay10TCYx(unsigned char);#else /* 17CXX */void Delay10TCYx(unsigned char);#endif/* Delay100TCYx * Delay multiples of 100 Tcy * Passing 0 (zero) results in a delay of 25,600 cycles. * The full range of [0,255] is supported. */#if __18CXXvoid Delay100TCYx(unsigned char);#else /* 17CXX */void Delay100TCYx(unsigned char);#endif/* Delay1KTCYx * Delay multiples of 1000 Tcy * Passing 0 (zero) results in a delay of 256,000 cycles. * The full range of [0,255] is supported. */#if __18CXXvoid Delay1KTCYx(unsigned char);#else /* 17CXX */void Delay1KTCYx(unsigned char);#endif/* Delay10KTCYx * Delay multiples of 10,000 Tcy * Passing 0 (zero) results in a delay of 2,560,000 cycles. * The full range of [0,255] is supported. */#if __18CXXvoid Delay10KTCYx(unsigned char);#else /* 17CXX */void Delay10KTCYx(unsigned char);#endif#endif
C:\test\single_servo.c:19: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x22):C:\test\single_servo.c:21: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x38):C:\test\single_servo.c:27: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x3c):C:\test\single_servo.c:28: undefined reference to `Delay100TCYx'single_servo.o(.text+0x44):C:\test\single_servo.c:30: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x48):C:\test\single_servo.c:31: undefined reference to `Delay100TCYx'single_servo.o(.text+0x5e):C:\test\single_servo.c:36: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x66):C:\test\single_servo.c:39: undefined reference to `Delay1KTCYx'
#include<stdio.h>#include<p24HJ32GP202.h>#include <delays.h>void main(void){int count=0;TRISB = 0x00;PORTB = 0x00; while(1) { for(count=0;count<50;count++) { //far counter-clockwise PORTB = 0x01; Delay1KTCYx(10); PORTB = 0x00; Delay1KTCYx(90); } //middle for(count=0;count<50;count++) { PORTB = 0x01; Delay1KTCYx(7); Delay100TCYx(5); PORTB = 0x00; Delay1KTCYx(92); Delay100TCYx(5); } for(count=0;count<50;count++) { //far counter-clockwise PORTB = 0x01; Delay1KTCYx(5); //Delay100TCYx(5); PORTB = 0x00; Delay1KTCYx(95); //Delay100TCYx(5); } }}
Clean: Deleting intermediary and output files.Clean: Deleted file "C:\test\single_servo.o".Clean: Done.Executing: "C:\Program Files (x86)\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=24HJ32GP202 -x c -c "single_servo.c" -o"single_servo.o" -g -Wallsingle_servo.c:6: warning: return type of 'main' is not 'int'single_servo.c:43:2: warning: no newline at end of fileExecuting: "C:\Program Files (x86)\Microchip\mplabc30\v3.25\bin\pic30-gcc.exe" -mcpu=24HJ32GP202 "single_servo.o" -o"single_servo.cof" -Wl,--script="C:\Program Files (x86)\Microchip\mplabc30\v3.25\support\PIC24H\gld\p24HJ32GP202.gld",-Map="single_servo.map",--report-memProgram Memory [Origin = 0x200, Length = 0x5600]section address length (PC units) length (bytes) (dec)------- ------- ----------------- --------------------.text 0x200 0x90 0xd8 (216).text 0x290 0x72 0xab (171).dinit 0x302 0x2 0x3 (3).isr 0x304 0x2 0x3 (3) Total program memory used (bytes): 0x189 (393) 1%Data Memory [Origin = 0x800, Length = 0x800]section address alignment gaps total length (dec)------- ------- -------------- ------------------- Total data memory used (bytes): 0 (0) Dynamic Memory Usageregion address maximum length (dec)------ ------- ---------------------heap 0 0 (0)stack 0x800 0x800 (2048) Maximum dynamic memory (bytes): 0x800 (2048)single_servo.o(.text+0x1a): In function `main':C:\test\single_servo.c:19: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x22):C:\test\single_servo.c:21: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x38):C:\test\single_servo.c:27: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x3c):C:\test\single_servo.c:28: undefined reference to `Delay100TCYx'single_servo.o(.text+0x44):C:\test\single_servo.c:30: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x48):C:\test\single_servo.c:31: undefined reference to `Delay100TCYx'single_servo.o(.text+0x5e):C:\test\single_servo.c:36: undefined reference to `Delay1KTCYx'single_servo.o(.text+0x66):C:\test\single_servo.c:39: undefined reference to `Delay1KTCYx'Link step failed.BUILD FAILED: Thu Jul 07 22:04:35 2011
void delay(int x){ int i; for(i=0 ;i<x; i++){ nop(); // putting code line here increases the delay time per loop } // and can keep the compiler from removing the loop}