Labiran, Simeon Olusola Guest
|
Serial communication |
Posted: Wed Jul 27, 2005 6:12 am |
|
|
Dear Young,
I compiled a programme to enable my PIC 18F452 communicate with PC through RS232. The Programme failed to build and the error result is :
" function used but not defined : set_timer_2 "
On line 8, i defined this function. What could have wrong withthis programme? Please, i need your advice.
My programme is as follow:
#include <18F452.h>
#include <stdio.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use fixed_io(C_outputs=pin_C6)
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
//#include <loader.c>
#define INTS_PER_SECOND 25 // (4000000/(4*16*250*10)
// set up timer
set_timer_2(T2_DIV_BY_16,250,10);
int8 seconds; //A running seconds counter
int8 int_count; // Numbering of interrupts left before a second has elapsed
#INT_TIMER2 // This function is called every time
void clock_isr(){ // Timer2 overflows (250 to 0) which is approaximately 25 times per second for this program
if(--int_count==0){
++seconds;
int_count=INTS_PER_SECOND;
}
}
void main(void)
{
int time;
unsigned int second;
unsigned int control; // 0=250
int_count=INTS_PER_SECOND;
set_timer_2(T2_DIV_BY_16,250,10);
set_timer2(0);
enable_interrupts(INT_TIMER2);
ENABLE_INTERRUPTS(global);
while (TRUE)
{
printf("press any key to begin.\n\r");
getc();
int_count=INTS_PER_SECOND;
seconds=0;
printf("press any key to stop.\n\r");
getc();
printf("%u seconds.\n\r", seconds);
}
}
/*
for (time = 0; time < 10; time++){
delay_us(10);
second = read_set_up_timer();
printf("numb=%u,second;
printf("time=%u",time);
getc(0);
getc(10);
*/ |
|