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

Help with Rs232 and putc

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







Help with Rs232 and putc
PostPosted: Tue Oct 26, 2004 11:44 am     Reply with quote

Hi everyone

I have trouble with this code, I received in my pc the data 0xFF 0x80 0xFF but I send 0xFF 0x00 0xFF .what is wrong. I use ccs 3.2 compiler


#include "C:\servo1.h"
#include <stdio.h>
#include <string.h>


void main()
{

setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(1)
{
delay_ms(500);

putc(0xFF);
delay_us(10);
putc(0x00);
delay_us(10);
putc(0xFF);




}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 26, 2004 11:52 am     Reply with quote

You need to post the first part of your program, such as
the #include statement for your .H file, and #fuses,
#use delay(), and #use rs232(), etc.
Also post the PIC that you are using and the FULL version number.
(ie., not "3.2", but 3.207, or 3.212, etc.)
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Oct 26, 2004 12:02 pm     Reply with quote

It looks like some sort of framing error. It could be inaccurate clocks giving inaccurate baud rates.
_________________
The search for better is endless. Instead simply find very good and get the job done.
jptalledo
Guest







code listing
PostPosted: Tue Oct 26, 2004 12:02 pm     Reply with quote

#include <16F876A.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,HS, PUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)




#include "C:\servo1.h"
#include <stdio.h>
#include <string.h>


void main()
{

setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(1)
{
delay_ms(500);

putc(0xFF);
delay_us(10);
putc(0x00);
delay_us(10);
putc(0xFF);

// delay_ms(500);

// putc(0xFF);
// putc(0x00);
// putc(0x00);


}
}


my compiler version is 3.203
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 27, 2004 8:06 am     Reply with quote

Are you using a Max232 chip? If so check the +V and -V voltage generated on the chip. They should be about +9.5v and -9.5v respectively. If not look for a capacitor installed incorrectly or a poor solder joint. This is a very common source of problems.

How are you powering the target? How is the ground connection commoned between the two systems?
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