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 CCS Technical Support

Help with RS232 issue on CCS proto. board

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



Joined: 30 Nov 2007
Posts: 10

View user's profile Send private message

Help with RS232 issue on CCS proto. board
PostPosted: Sat Dec 01, 2007 5:04 am     Reply with quote

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







PostPosted: Sat Dec 01, 2007 10:26 am     Reply with quote

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

View user's profile Send private message

Settings ?
PostPosted: Sat Dec 01, 2007 3:13 pm     Reply with quote

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

View user's profile Send private message

Re: Settings ?
PostPosted: Sat Dec 01, 2007 3:22 pm     Reply with quote

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
Very Happy
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