pic c programming help!

Thread Starter

purejoker

Joined Feb 15, 2009
3
hi there, im a bit stuck on a project im working on. What the project has to get reading from 4 digital temperature sensors and output them on hyperterminal. so this is the code that i have come up with, but it does not seem to work, can someone please guide me as were im am going wrong?
Im using a pic16f877a with a max233cpp chip and a 4mhz crystal resonator.

Thanks for your help
Pure!
Rich (BB code):
#include <16F877A.H>
#use delay (clock=4000000)
#use rs232(baud=2400,xmit=PIN_E0,rcv=PIN_E1)
unsigned int32 read1;
unsigned int32 read2;
unsigned int32 read3;
unsigned int32 read4;
int8 sem;
//
// Define which timer to use and minor_cycle for RTOS
//
#use rtos(timer=1, minor_cycle=100ms)

// Declare TASK "Get_Reading" - called every 10ms

#task(rate=2s, max=100ms)
void Get_Reading()
{
rtos_wait(sem); // decrement semaphore
read1 = input(PIN_C0);
read2 = input(PIN_C1);
read3 = input(PIN_C2);
read4 = input(PIN_C3);
rtos_signal(sem); // increment semaphore
}
//
// Declare TASK "To_RS232" - called every millisecond
//
#task(rate=2s, max=100ms)
void To_RS232()
{
rtos_wait(sem); // Decrement semaphore
printf("Reading = %LumV\n\r",read1); // Send to RS232
printf("Reading = %LumV\n\r",read2); // Send to RS232
printf("Reading = %LumV\n\r",read3); // Send to RS232
printf("Reading = %LumV\n\r",read4); // Send to RS232
rtos_signal(sem); // Increment semaphore
}
//
// Start of MAIN program
//
void main()
{
set_tris_c(0xFF); // PORT C all inputs
delay_us(10);
sem = 1; // Semaphore is 1
rtos_run(); // Start RTOS
}
 
Top