PCWHD IDE COMPILER Custom Computer Services Inc (CCS), PCWHD IDE COMPILER Datasheet - Page 346

PCWHD PIC10,16,18,24, DSPIC

PCWHD IDE COMPILER

Manufacturer Part Number
PCWHD IDE COMPILER
Description
PCWHD PIC10,16,18,24, DSPIC
Manufacturer
Custom Computer Services Inc (CCS)
Type
Compilerr
Datasheet

Specifications of PCWHD IDE COMPILER

For Use With/related Products
Microchip PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC MCUs
Lead Free Status / RoHS Status
Not applicable / Not applicable
Other names
429-1009
How do I get getc() to timeout after a specified time?
GETC will always wait for a character to become available unless a timeout time is specified in the
#use rs232().
The following is an example of how to setup the PIC to timeout when waiting for an RS232
character.
#include <18F4520.h>
#fuses HS,NOWDT
#use delay(clock=20MHz)
#use rs232(UART1,baud=9600,timeout=500) //timeout = 500 milliseconds, 1/2
second
void main()
{
}
How do I wait only a specified time for a button press?
The following is an example of how to wait only a specific time for a button press.
#define PUSH_BUTTON PIN_A4
int1 timeout_error;
int1 timed_get_button_press(void){
}
332
char c;
while(TRUE)
{
}
int16 timeout;
timeout_error=FALSE;
timeout=0;
while(input(PUSH_BUTTON) && (++timeout<50000)) // 1/2 second
if(!input(PUSH_BUTTON))
else{
}
c=getc();
if(c) //if not zero echo character back
//user to do code
output_toggle(PIN_A5);
delay_us(10);
return(TRUE); //button pressed
timeout_error=TRUE;
return(FALSE); //button not pressed timeout occurred
putc(c);
//if getc() timeouts 0 is returned to c
//otherwise receive character is returned to c

Related parts for PCWHD IDE COMPILER