|
|
View previous topic :: View next topic |
Author |
Message |
red_one
Joined: 30 Nov 2007 Posts: 10
|
Help with RS232 issue on CCS proto. board |
Posted: Sat Dec 01, 2007 5:04 am |
|
|
Hello
I have a CCS Prototyping Board with a PIC16F877A MCU. I'm testing example on the exercise book using rs232 port (ex10 )
ex10.c code:
Code: | #include "protoalone.h"
#include <stdlib.h>
#include <input.c>
void main() {
long a, b, result;
char opr;
setup_timer_1(RTCC_INTERNAL);
while (TRUE) {
printf("\r\nEnter the first number: ");
a = get_long();
do {
printf("\r\nEnter the operator (+-*/): ");
opr = getc();
} while (!isamoung(opr, "+-*/"));
printf("\r\nEnter the second number: ");
b = get_long();
switch (opr) {
case '+' : result = a + b; break;
case '-' : result = a - b; break;
case '*' : result = a * b; break;
case '/' : result = a / b; break;
}
printf("\r\nThe result is %lu ", result);
}
} |
protoalone code:
Code: | #include <16f877A.h>
#fuses HS, NOLVP, NOWDT, PUT
#use delay(clock=20000000)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8)
#define PUSH_BUTTON PIN_A4
#define FIRST_LED PIN_A5
#define SECOND_LED PIN_B4
#define THIRD_LED PIN_B5 |
after compile I load the program into the Prototyping board (Tools/ICD) then I disconnect the board power and the ICD. After this I power up only the proto board and plug in the serial cable.
All I get on the terminal is garbage and entering the numbers doesn't work.
Code: | 12.01.2007 11:40:16.617 --> 怘€f0øž`?fž?ÌæfÃ`x3óÃøæøó`žffφàfÆø†~Àü |
I verified the connection. It's on the Com4. The jumpers are set as shown on the book (7=> 12 and 8 => 11). |
|
|
Ttelmah Guest
|
|
Posted: Sat Dec 01, 2007 10:26 am |
|
|
What you are displaying, is 'classic' for the baud rate being wrong somewhere. Check that the com port in your PC, is set to 9600baud 8bits no parity, and that the crystal on the board you are using, is 20MHz. It looks exactly as if the data is taking twice as long to send as 'expected', so either the PC is set to 19200bps, or the crystal on the board is 10MHz, not 20MHz.
Best Wishes |
|
|
red_one
Joined: 30 Nov 2007 Posts: 10
|
Settings ? |
Posted: Sat Dec 01, 2007 3:13 pm |
|
|
Ttelmah wrote: | What you are displaying, is 'classic' for the baud rate being wrong somewhere. Check that the com port in your PC, is set to 9600baud 8bits no parity, and that the crystal on the board you are using, is 20MHz. It looks exactly as if the data is taking twice as long to send as 'expected', so either the PC is set to 19200bps, or the crystal on the board is 10MHz, not 20MHz.
Best Wishes |
I've verified. Speed is set to 9600baud, parity none, 8 bits.
The crystal frequency is 10MHz.
I'll try to change this in the code and reply later.
Thanks |
|
|
red_one
Joined: 30 Nov 2007 Posts: 10
|
Re: Settings ? |
Posted: Sat Dec 01, 2007 3:22 pm |
|
|
red_one wrote: | Ttelmah wrote: | What you are displaying, is 'classic' for the baud rate being wrong somewhere. Check that the com port in your PC, is set to 9600baud 8bits no parity, and that the crystal on the board you are using, is 20MHz. It looks exactly as if the data is taking twice as long to send as 'expected', so either the PC is set to 19200bps, or the crystal on the board is 10MHz, not 20MHz.
Best Wishes |
I've verified. Speed is set to 9600baud, parity none, 8 bits.
The crystal frequency is 10MHz.
I'll try to change this in the code and reply later.
Thanks |
It works.
Thanks Ttelmah
|
|
|
|
|
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
|