Maker Pro
Maker Pro

Please help: RS232 problem

M

ma

Jan 1, 1970
0
Hello,

I have build a PIC based on 18f2620 and write a very simple code
that would put 1 'a' to rs232 to test that the board working well.



I used PIC-C compiler from CCS and use the following line to setup rs232 in
C program:



#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)



and the source code is as follow:



void main()

{

int8 i;

setup_adc_ports(AN0_TO_AN1|VSS_VDD);

setup_adc(ADC_OFF|ADC_TAD_MUL_0);

setup_spi(FALSE);

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_comparator(NC_NC_NC_NC);

setup_vref(FALSE);

// enable_interrupts(INT_RTCC);

// enable_interrupts(GLOBAL);

for(i=0;i<10;i++)

{

putc('a');

}



}



I used the build in "serial port monitor" in PIC-C to read the comport in
PC.



What I got in PC is 20 timnes of 00. exactly two times the number of chars
that I write to comport in PIC but the data is always zero.



The setup in PC is as follow:



Buad rate 9600

Parity=non

Data bit=8

Stopbit=1

Software flow control = non

Hardware flow control= use DTR, use RTS, Req DRS, Req CTS.



What is the problem?



One note: I used the maxim IC to transfer level from TTL to RS232 so I think
the level should be ok.



Is it a hardware problem or a software problem?

Did you every had such problem before? Any help appreciated



Best regards
 
J

James Beck

Jan 1, 1970
0
Hello,

I have build a PIC based on 18f2620 and write a very simple code
that would put 1 'a' to rs232 to test that the board working well.



I used PIC-C compiler from CCS and use the following line to setup rs232 in
C program:



#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
Did you remember the

#use delay(clock=XXXXXX,RESTART_WDT)
(for example : #use delay(clock=4000000,RESTART_WDT))

where clock is your osc frequency in hz?
Without it CCS can't guess how to set up the UART, but I would think it
should give an error about the missing information.
 
M

ma

Jan 1, 1970
0
Yes there is this command there:
#use delay(clock=8000000)

the osc set to be a RC oscilator and the fuse command is:
#fuses NOWDT,WDT128,INTRC_IO, NOPROTECT, NOIESO, NOBROWNOUT, BORV21, PUT,
NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB,
NOWRTC, NOWRTB, NOFCMEN, XINST, NOPBADEN, NOLPT1OSC, NOMCLR

Are they correct?

Best regards
Mansour
 
J

James Beck

Jan 1, 1970
0
Yes there is this command there:
#use delay(clock=8000000)

the osc set to be a RC oscilator and the fuse command is:
#fuses NOWDT,WDT128,INTRC_IO, NOPROTECT, NOIESO, NOBROWNOUT, BORV21, PUT,
NOCPD, STVREN, NODEBUG, NOLVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB,
NOWRTC, NOWRTB, NOFCMEN, XINST, NOPBADEN, NOLPT1OSC, NOMCLR

Are they correct?

I don't see anything that is a show stopper. Myabe the RC osc osc WAY
off of 8Mhz and the baud rate is not actually 9600?

Jim
 
Top