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

RS232 problem (not receive the data from the computer)

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







RS232 problem (not receive the data from the computer)
PostPosted: Mon Nov 12, 2007 1:08 am     Reply with quote

hell All:

I have an 18f4550 and MAX3232CPE chip that i am using to communicate with a computer (hyperterminal).

RS232_PIN_2 ----PIN7_MAX3232_PIN10---------PIN_A3_18f4550
RS232_PIN_3 ----PIN8_MAX3232_PIN9---------PIN_A2_18f4550

sending data to the computer using printf==>OK

But not receive the data from the computer

#include <18F4550.h>
#fuses hs,NOWDT,PROTECT,NOLVP,NODEBUG,MCLR,NOVREGEN
#use delay (clock=8000000)
#use rs232(baud=9600,parity=N, xmit=PIN_A3,rcv=PIN_A2,bits=8)
/////////////////////////////////////////////////////////////
void main(void){
char c;
printf("\r\n\RS-232 int is ok \r\n\n"); // have display ,is ok
while(TRUE){
c = getc(); //have problem!!!
putc(c); //no display is NG
printf("\r\nSize: %u Bytes\r\n",c); //no display is NG
}

}
Evan
Guest







Re: RS232 problem (not receive the data from the computer)
PostPosted: Mon Nov 12, 2007 1:11 am     Reply with quote

Evan wrote:
hell All:

I have an 18f4550 and MAX3232CPE chip that i am using to communicate with a computer (hyperterminal).

RS232_PIN_2 ----PIN7_MAX3232_PIN10---------PIN_A3_18f4550
RS232_PIN_3 ----PIN8_MAX3232_PIN9---------PIN_A2_18f4550

sending data to the computer using printf==>OK

But not receive the data from the computer
Version 4.057

#include <18F4550.h>
#fuses hs,NOWDT,PROTECT,NOLVP,NODEBUG,MCLR,NOVREGEN
#use delay (clock=8000000)
#use rs232(baud=9600,parity=N, xmit=PIN_A3,rcv=PIN_A2,bits=8)
/////////////////////////////////////////////////////////////
void main(void){
char c;
printf("\r\n\RS-232 int is ok \r\n\n"); // have display ,is ok
while(TRUE){
c = getc(); //have problem!!!
putc(c); //no display is NG
printf("\r\nSize: %u Bytes\r\n",c); //no display is NG
}

}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Nov 12, 2007 4:31 am     Reply with quote

In the PIC processor the I/O pins are multiplexed for use by several hardware functions. On program startup you have to configure the I/O pins for the hardware function that you want to use. Check the datasheet of the PIC18F4550, Table 10-1 for pin A2:
Quote:
PORTA<2> data input. Disabled when analog functions enabled;

By default PIN_A2 is configured as an analog input, if you want to use it as a digital input you have to disable the analog port:
Code:
setup_adc_ports(NO_ANALOGS);


Just wondering: Why are you not using the hardware UART on pins C6 and C7?
Evan
Guest







Now is the same question
PostPosted: Mon Nov 12, 2007 6:32 pm     Reply with quote

Hi ckielstra

Now is the same question =>not receive the data from the computer.

Im using the hardware SPI on pins C7,B0,B1 Connection SD CARD .
Thanks for your reply.
Evan
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