arrow
Joined: 17 May 2005 Posts: 213
|
RS232 controlled clock?- Simple Question |
Posted: Wed Nov 23, 2005 6:36 am |
|
|
Hi
I would like to implement a count down clock. I have used the INT_RTCC successfully to achieve this.
Now I would like to send a number from the PC, and for the PIC16F84A to pick up the number being sent, and reset the count down based on the number sent. I am not sure how to do this.
Can someone please give me a guideline to follow?
Thank you in advance.
a. |
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 23, 2005 1:28 pm |
|
|
Quote: |
Now I would like to send a number from the PC, and for the
PIC16F84A to pick up the number being sent. |
Look in the CCS file, INPUT.C, for these functions:
(The INPUT.C file is in this folder: C:\Program Files\PICC\Drivers )
get_int()
get_long()
These allow you to send a number from the PC to the PIC, and
convert it to a binary value, which you can use in your program.
ie., you can put the number into an int8 or an int16 ("long") variable.
Example:
Code: | #include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use RS232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#include <stdlib.h>
#include <input.c>
//=============================
void main()
{
signed int8 value;
while(1)
{
printf("Enter a number: ");
value = get_int(); // Get the number from the PC
printf("\n\r");
printf("value = %d\n\r", value); // Display it
}
} |
|
|