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 support@ccsinfo.com

RS232 sending characters problem

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



Joined: 04 Aug 2007
Posts: 18

View user's profile Send private message

RS232 sending characters problem
PostPosted: Mon Aug 13, 2007 10:13 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 13, 2007 10:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 13, 2007 1:20 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Aug 13, 2007 2:41 pm     Reply with quote

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:
Code:
  printf("%u", x);

This will send the same ASCII chars to your PC, as are sent to the LCD.
Dominik



Joined: 04 Aug 2007
Posts: 18

View user's profile Send private message

PostPosted: Wed Aug 15, 2007 11:36 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 15, 2007 11:49 am     Reply with quote

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.
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