|
|
View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
wrong communication data transfer |
Posted: Wed Jul 21, 2004 12:41 pm |
|
|
I have used
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
int8 val1;
val1=235;
printf("%2u",val1);
to sent data to serial port com1, and using the miscrosoft communication control 6.0 to receive dat, however, the data I reveived was strange character, what might cause this problem? |
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 1:41 pm |
|
|
any hint? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Jul 21, 2004 2:10 pm |
|
|
Could you at least tell us what the strange character was, preferably the binary value? _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 2:27 pm |
|
|
Following is my RS232 testing file,
after download the file to the chip. I tried to monitor the result using serial port monitor under CCS PCW compiler, all data are zero, what is wrong with this program?
Code: |
#if defined(__PCM__)
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
//I connected RX to RC7, TX to RC6
void main() {
BYTE value;
int val1;
setup_port_a(ALL_ANALOG);
setup_adc( ADC_CLOCK_INTERNAL );
do {
set_adc_channel( 1 );
delay_us(50);
val1 = Read_ADC();
printf("%u\r\n",val1);
delay_ms(1000);
} while (TRUE);
}
|
|
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 2:43 pm |
|
|
I could not type the character, it looks like the 0b11100001 in windows screen. however all 0 when I use the serial monitor. in order to find out what is wrong step by step, I made the above program only ccs and same result, what is wrong with the ccs c program? maybe after I find out problem here, I could go another step to vc programming. |
|
|
valemike Guest
|
Check your hardware |
Posted: Wed Jul 21, 2004 2:51 pm |
|
|
Code: |
#include <18F448.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main() {
BYTE value;
int val1;
setup_port_a(ALL_ANALOG);
setup_adc( ADC_CLOCK_INTERNAL );
do {
set_adc_channel( 1 );
delay_us(50);
val1 = Read_ADC();
printf("%u\r\n",val1);
delay_ms(1000);
} while (TRUE);
}
|
My output looked like:
Code: |
111
112
112
112
112
112
112
112
111
112
111
111
112
|
No garbage characters when I printed it out. Check your hardware to make sure your connections are correct. I used Hyperterminal to print my chars out... (9600-8-N-1) |
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 2:53 pm |
|
|
after I changed the baud rate it is now showing F0 00 00 00 00 00 F0 00 00, I also changed printf("%u\r\n",val1) to printf("%u",val1) |
|
|
Ttelmah Guest
|
|
Posted: Wed Jul 21, 2004 2:56 pm |
|
|
Anonymous wrote: | after I changed the baud rate it is now showing F0 00 00 00 00 00 F0 00 00, I also changed printf("%u\r\n",val1) to printf("%u",val1) |
How are you connecting the serial?.
Best Wishes |
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 3:02 pm |
|
|
When I use my original program, it is showing F0 00 00 F0 F0 F0 00 00 F0 00, F0 00 00 00 00 f0 00, 00 00 00 f0 00 00 00 00, 00 00 00 00 f0 00 f0 00 00. |
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 3:06 pm |
|
|
I connected com1 with RS232 port on my PICeasy2 board, and RX was connected with RC7, TX was connected with RC6? |
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 3:13 pm |
|
|
what you mean hyperterminal, I do not know the word yet. is it the serial monitor in PCW IDE |
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 3:22 pm |
|
|
Ok, I found hyperterminal. |
|
|
Guest
|
|
Posted: Wed Jul 21, 2004 3:33 pm |
|
|
when I use hyperterminal, there is nothing happened? |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Wed Jul 21, 2004 4:26 pm |
|
|
any further help? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Jul 21, 2004 5:58 pm |
|
|
Are you using a RS232 transceiver chip like a Max232 between the PC serial port and the PIC? |
|
|
|
|
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
|