View previous topic :: View next topic |
Author |
Message |
Dominik
Joined: 04 Aug 2007 Posts: 18
|
Hexa command sending problem |
Posted: Mon Oct 01, 2007 9:32 am |
|
|
I'm using a PIC 16F877A and I try to send a command "0x0D" on the rs232 but it's not working.
My program is
Code: |
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main() {
int x;
x=0x0D;
do {
printf("%x", x);
} while (TRUE);
}
|
I tried also "%2x" or "%c" and putc(0x0D) but it's not working too.
Any help will be very welcome.
Dominik |
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Mon Oct 01, 2007 9:43 am |
|
|
try
|
|
|
Dominik
Joined: 04 Aug 2007 Posts: 18
|
|
Posted: Mon Oct 01, 2007 11:06 am |
|
|
This is not working too ...
But there's something strange because the program seems to work with the CCS PCM C Compiler, Version 4.013 and doesn't working with mine's CCS PCM C Compiler, Version 4.038. |
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Mon Oct 01, 2007 11:14 am |
|
|
How is it not working exactly?
Are you getting an error message when you compile?
I'm using 4.038 and have no problems. |
|
|
Dominik
Joined: 04 Aug 2007 Posts: 18
|
|
Posted: Mon Oct 01, 2007 11:23 am |
|
|
The program is compiled good but the datas sent are strange characters and the ones in the program.
Might come from this part ?
Code: | #include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
|
|
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Mon Oct 01, 2007 12:32 pm |
|
|
I doubt it is a problem with the part, it's more likely that your PC's baudrate is slightly off, or your crystal is not exactly 4Mhz
Try a slower baudrate like 1200
Give this a try too.
Code: |
#pragma use rs232( stream = UART_1 , baud = 1,200, UART1, parity = N, BITS = 8 )
fprintf( UART_1, "\r" );
|
|
|
|
|