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

About the RS232 test

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



Joined: 15 Oct 2006
Posts: 18
Location: Taiwan

View user's profile Send private message MSN Messenger

About the RS232 test
PostPosted: Wed Nov 01, 2006 3:17 am     Reply with quote

Dear all

I am new comer for CCS but I have so many problems about using CCS 4.0.12.
Original I try to use PIC12F683 using software RS232 to communicate with PC. But it always fail. I give up.
Now I try to think it should be OK using the hardware RS232 for PIC18F452. But it also fail again.
I post my probelm and please someone to teach me what is the matter.

#include <18F452.h>
#device adc=8

#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOOSCSEN //Oscillator switching is disabled, main oscillator is source
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES NOPUT //No Power Up Timer
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES DEBUG //Debug mode for use with ICD
#FUSES LVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOCPD //No EE protection
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads

#use delay(clock=10000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=ABC)
// #use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3)





#include "F:\Download\Working\CCS\11012006\PIC18F452.h"


void main()
{

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_oscillator(False);
set_tris_C(0xb7) ;
// TODO: USER CODE!!

delay_ms(255) ;
fputs("test\r",ABC) ;
// input=fgetc(rs232) ;
output_drive(PIN_A0) ;
output_high(PIN_A0) ;
while(1)
{output_toggle(PIN_A0) ;
fputs("test\r",ABC) ;
delay_ms(100) ;
//input=fgetc(rs232) ;


}
}
Ttelmah
Guest







PostPosted: Wed Nov 01, 2006 4:20 am     Reply with quote

A series of questions apply.
First, are you using low voltage programming?. If you are, you need to have a pull down resistor on the programming pin. If not, get rid of the 'LVP' fuse, and replace it with 'NOLVP'.
Second, you have 'DEBUG' mode selected. Are you running with a debugger?. If not, the this needs to change.
Next, is your clock 10MHz?.
Next, the big one, How is the connection made to the PC?. You need a MAX232, buffer/inverter, or a circuit to provide a similar function.
Then, general ones round the chip. What is connected to MCLR?. Have you got both supply pins connected?. What decoupling is present?.
Then, simplify your diagnostics.
Have a really short 'main' loop, that just sits toggling a pin (effectively your curent code with every RS232 line removed). Check this pin _is_ toggling. If not, then your chip is not running,and the problem is probably one of the connections like MCLR. Once you have this running, check the frequency. Is it about 5Hz (with the delay shown in your code)?. If not, your oscillator figures are wrong somewhere. Only once this is working, try to progress to the RS232 testing.

Best Wishes
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