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

problem serial port 18f8722

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







problem serial port 18f8722
PostPosted: Mon Oct 19, 2009 5:50 am     Reply with quote

Hi to everyone.

I am trying to communicate a 18F8722 with a modem via serial port rs232. I have some problems because the comm does not work. I guess I have some problems with the #fuses. I wrote a very simple code to write a string to the modem. Here's my code:

-define.h file:
Code:

//define.h
#device adc=10
#fuses NOWDT,WDT32768,H4,NOPROTECT,NOIESO,NOBROWNOUT,BORV25,NOPUT, NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOCPB, NOEBTRB,NOEBTR,NOWRTD,NOWRTC,NOWRTB,NOFCMEN,NOLPT1OSC,MCLR,NOXINST,MCU
//-----------------------------com serie --------------------------------------
//#use delay(clock=40000000)
#use delay(clock=38400000)

#use rs232(baud=9600,parity=N,UART1, xmit=PIN_C6, rcv=PIN_C7, bits=8,STOP=1, stream=MODEM)


-main:
Code:

//main.c

#include <18F8722.h>
#include <define.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>


void main(void) {
   setup_oscillator(OSC_32MHZ);

   fputs("0104pppp",MODEM);

      while(true){  }
}

The serial comm just does not work. Could someone give me some hints?
Thanks in advance.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 19, 2009 10:58 am     Reply with quote

Quote:

#use delay(clock=38400000)


void main(void) {
setup_oscillator(OSC_32MHZ);

fputs("0104pppp",MODEM);

while(true){ }
}

The serial comm just does not work.

You are setting the internal oscillator frequency to 32 MHz, but you are
telling the compiler that it's 38.4 MHz. That's wrong. The #use delay()
value must always match the oscillator frequency. The compiler uses
the #use delay() value to calculate the baud rate register value for the
UART.
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