View previous topic :: View next topic |
Author |
Message |
Dominik
Joined: 04 Aug 2007 Posts: 18
|
RS232 sending characters problem |
Posted: Mon Aug 13, 2007 10:13 am |
|
|
I have a problem when I want to send some characters from my Picdem 2 Demo Board with an 16F877A pic module to my computer via the rs232 com using the hyperterminal application.
The characters I'm receiving are only "pppppppppppppppppppppp".
this is the code of my program :
Code: |
#if defined(__PCM__)
#include <16F877A.h>
#device *=16
#fuses HS,NOLVP,NOWDT,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOLVP,NOWDT,NOPROTECT
#use delay(clock=20000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=N, bytes=8)
#endif
#include "Flex_LCD.c"
// Included for card read functionality
#include "24256Dem.c"
#define LCD_POWER PIN_D7
void main()
{
int index;
int x;
while(TRUE)
{
output_high(LCD_POWER); // Turn on power to LCD
output_low(LCD_RW); // Set R/W pin on LCD to a low level
lcd_init(); // Initialize the LCD
printf("Datas :");
index=0;
do{
x=(READ_EXT_EEPROM( index ) );
putc(x);
printf(lcd_putc, "%u", x);
index++;
}while(index<16);
}
}
|
The characters displayed on the LCD are the right ones, so that's why I don't understand why I don't have them on the screen of my computer.
Thank you for any help.
Dominik |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Mon Aug 13, 2007 10:59 am |
|
|
Are you getting anything at all on your PC?
Try using SIOW that came with the CCS compiler instead of hyperterm.
Can you use a scope to verify the baud rate?
Could you have the polarity reversed?
What is your compiler version? _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
Dominik
Joined: 04 Aug 2007 Posts: 18
|
|
Posted: Mon Aug 13, 2007 1:20 pm |
|
|
I can't use siow for that application.
My compiler version is 4.038.
Can you please explain to me what is the polarity reversed ?
Thanks
Dominik |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 13, 2007 2:41 pm |
|
|
Quote: | x=(READ_EXT_EEPROM( index ) );
putc(x);
printf(lcd_putc, "%u", x);
index++;
}while(index<16);
The characters displayed on the LCD are the right ones, so that's why I
don't understand why I don't have them on the screen of my computer.
|
The putc(x) statement sends the raw byte value to the PC.
The printf() statement with "%u" converts the value to one or more ASCII digits and sends them to the LCD.
You need to change the putc(x) statement to this:
This will send the same ASCII chars to your PC, as are sent to the LCD. |
|
|
Dominik
Joined: 04 Aug 2007 Posts: 18
|
|
Posted: Wed Aug 15, 2007 11:36 am |
|
|
I tried to change as you said to me but I stil have the same problem of display on my computer.
It is possible to send in the datas in a file, as a *.txt or *.rtf ?
Like this I won't have any problem about display, but I didn't find anything about that topic on the ccs manual.
Thank you for helping me.
Dominik |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 15, 2007 11:49 am |
|
|
Quote: |
I tried to change as you said to me but I stil have the same problem of
display on my computer. |
Make a simple test program and get the serial port working.
Here's a program that is for a 16F876A. It should work with your PIC.
Just change the .H file to a 16F877A.
http://www.ccsinfo.com/forum/viewtopic.php?t=29538&start=6
Make sure you setup your terminal program to run at 9600 baud,
no parity, 8 bits, 1 stop bit. |
|
|
|