x_Stickler_x
Joined: 27 Mar 2008 Posts: 3
|
rs232 problem (Serial Port Monitor) |
Posted: Thu Jul 17, 2008 1:11 pm |
|
|
When I compile the program from the "Tools>ICD" menu how do I run it in the "Tools>Serial Port Monitor" menu?
When I go here I don't know what to do.
The PIC18f4520 developer exercise book isn't very descriptive.
When I load the program onto the chip, then unplug the power to dissconnect the ICD-U40, then power back on the proto board, nothing happens.
Is anything wrong with the code CCS is providing or is it on my end?
Program:
Code: | #include <protoalone.h>
#include <stdlib.h>
#include <input.c>
/*9 lines below are #include <protoalone.h> w/o ICD=TRUE*/
/*#include <18f4520.h>
#fuses HS,NOLVP,NOWDT
#use delay (clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#define GREEN_LED PIN_A5
#define YELLOW_LED PIN_B4
#define RED_LED PIN_B5
#define PUSH_BUTTON PIN_A4*/
void main()
{
long a,b,result;
char opr;
setup_timer_0 (RTCC_INTERNAL);
while(TRUE)
{
printf("\r\nEnter the first number:");
a=get_long();
do{
printf("\r\nEnter the operator (+-*/):");
opr=getch();
} while(!isamoung(opr,"+-*/"));
printf("\r\nEnter the second number:");
b=get_long();
switch(opr)
{
case '+' : result=a+b; break;
case '-' : result=a-b; break;
case '*' : result=a*b; break;
case '/' : result=a/b; break;
}
printf("\r\nThe result is %lu",result);
}
} |
|
|