Hi.
Been struggling for awhile with this code:
I've used the attached schematic, and I found the code in the Hi Tech C sample directory.
It's connected to Hyperterminal, and when I push the reset button, I get a message on the screen saying:"Press a key and I will echo it back:".
When I press any key, it doesn't respond. When I press the reset button, it starts over.
I've tried with getchar, getch, getche, all found in the headerfiles, and no errors while compiling.
I've tested the cable, and it seems to work ok.
What could cause this?
I'm using MPLAB 8.63, Hi Tech C v9.80
Been struggling for awhile with this code:
Rich (BB code):
#include <stdio.h>
#include <htc.h>
#include <conio.h>
#include "usart.h"
#define _XTAL_FREQ 4000000
/* Configuration */
__CONFIG (WDTDIS & PWRTEN & MCLREN & BOREN & LVPDIS & UNPROTECT & INTIO);
void main(void)
{
unsigned char input;
INTCON=0; // purpose of disabling the interrupts.
init_comms(); // set up the USART - settings defined in usart.h
// Output a message to prompt the user for a keypress
printf("\rPress a key and I will echo it back:\n\r");
while(1)
{
input = getchar(); // read a response from the user
printf("\n\rI detected [%c]",input); // echo it back
} // end while
} // end main
It's connected to Hyperterminal, and when I push the reset button, I get a message on the screen saying:"Press a key and I will echo it back:".
When I press any key, it doesn't respond. When I press the reset button, it starts over.
I've tried with getchar, getch, getche, all found in the headerfiles, and no errors while compiling.
I've tested the cable, and it seems to work ok.
What could cause this?
I'm using MPLAB 8.63, Hi Tech C v9.80
Attachments
-
8.9 KB Views: 147