CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Pic to pic code question ...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
J_D



Joined: 24 Apr 2005
Posts: 1

View user's profile Send private message

Pic to pic code question ...
PostPosted: Sun Apr 24, 2005 11:30 am     Reply with quote

Hello CCS community:

I am new to programming pic micro-controllers and am having trouble trying to get two pic16F87/88s to communicate with each other. My seriaI communication with the PC is working fine (I get "g"s in the hyperterminal), but when I try to input from keyboard over serial line, type "g", I get nothing. I am posting two programs below. Does anyone see anything in my software code that is incorrect? Question Please let me know. Thanks. - J_D

Program 1:

//this is an example of use of "printf" function
//this a way for us to communicate with MCU

//NOTE: We will set up serial communication
//between PC and MCU using MAX232 transceiver chip

//Last Updated: Sun 01/30/2005
//Dima

#include <../../16F88.H> // tell the CCS compiler which chip we are using

#fuses INTRC, NOWDT, NOPROTECT, NOBROWNOUT, PUT, NOLVP, NOMCLR
//select internal oscillator, no watchdog timer, no code protection,
//disable brownout detection, enable power up timer
//disable low voltage programming mode, disable reset pin

#use standard_io(A) // allow for input-output on port A
#use standard_io(B) // allow for input-output on port B

#use delay(clock=8000000) // tell the compiler what speed clock you are using

#use rs232(baud=9600, xmit=PIN_B5, rcv=PIN_B2)
//set up communication lines, transmit on portB pin 5 and recieve on
portB pin two

//-------------------------------------------------
#define TEST_PIN PIN_A0
#define ONE_SEC 1000
#define ONEHALF_SEC 500
#define QUATER_SEC 250
//-------------------------------------------------

void main()
{
setup_oscillator(OSC_8MHZ | OSC_INTRC); //set up internal oscillator
to run at
//8 million clicks per second

while(TRUE) //loop forever
{
delay_ms(ONEHALF_SEC); // wait for 500 milliseconds

output_high(TEST_PIN);
printf("g");
delay_ms(QUATER_SEC);
output_low(TEST_PIN);
}
}


Program 2:

//this is an example of how we can read character
//input from keyboard over serial line

//NOTE: We will set up serial communication
//between PC and MCU using MAX232 transiver chip

//Last Updated: Sat 02/12/2005
//Dima

#include <16F88.H> // tell the CCS compiler which chip we are using

#fuses INTRC, NOWDT, NOPROTECT, NOBROWNOUT, PUT, NOLVP, NOMCLR
//select internal oscillator, no watchdog timer, no code protection,
//disable brownout detection, enable power up timer
//disable low voltage programming mode, disable reset pin

#use standard_io(A) // allow for input-output on port A
#use standard_io(B) // allow for input-output on port B

#use delay(clock=8000000) // tell the compiler what speed clock you are using

#use rs232(baud=9600, xmit=PIN_B5, rcv=PIN_B2, stream=FROMPIC_1)
#use rs232(baud=9600, xmit=PIN_B1, rcv=PIN_B0, stream=TO_PC)

//set up communication lines, transmit on portB pin 5 and recieve on
portB pin two
//NOTE: these correspond to hardware UART tx and rx pins

//-------------------------------------------------
#define TEST_PIN PIN_A0
#define TEST_INPUT PIN_A2
#define ONE_SEC 1000
#define ONEHALF_SEC 500
#define QUATER_SEC 250
//-------------------------------------------------

void main()
{
int a;
setup_oscillator(OSC_8MHZ|OSC_INTRC); //set up internal oscillator to run at
//8 million clicks per second

while(TRUE) //loop forever
{
a=fgetc(FROMPIC_1); //start looking for any character on serial
input line
//if ANY character is detected procede to the next statement

if(a=='g') //"g" key is pressed on the keyboard
{
fprintf(TO_PC,"Oh yeah, I found the g \n\r");
delay_ms(QUATER_SEC); //delay a bit before reading again
}
}
}



Thanks again for your help!




Question
aami
Guest







Hey I have the same problem
PostPosted: Mon Nov 06, 2006 12:51 pm     Reply with quote

Hi J_D
Has your problem solved? I am having the exact same problem.

cheers
domdom



Joined: 06 Sep 2006
Posts: 29

View user's profile Send private message

PostPosted: Sat Mar 17, 2007 7:28 am     Reply with quote

J_D ,

have you solved your problem?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group