asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
16f1509 no apparent RS232 support [solved] |
Posted: Tue Jul 23, 2013 4:26 pm |
|
|
Code: |
#include <16f1509.h>
#Fuses XT,NOWDT,PUT,NOMCLR,NOPROTECT,NOBROWNOUT,NOIESO
#Fuses NOFCMEN,NOWRT,NOSTVREN,NODEBUG,NOLVP
#use delay( clock=2097152 ) // using power of 2 Xtal
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#include <stdlib.h>
#byte RCSTA = 0x19D
#byte TXSTA = 0x19E
#bit SPEN = RCSTA.7
#bit TXEN = TXSTA.5
#bit SYNC = TXSTA.4
//******
MAIN() {
//******
output_a (0); output_b (0); output_c (0);
set_tris_a (0b11111110); // - all INPUT OUT= A0,
set_tris_b (0b11111111); // all input
set_tris_c (0);
setup_adc_ports( NO_ANALOGS );
setup_adc( ADC_OFF );
#use rs232(baud=9600, rcv=PIN_B5, xmit=PIN_B7, ERRORS )
SPEN=1; // output TX pin does not go high w/o this added
TXEN=1; // hail mary per Datasheet
SYNC=0; // hail mary per Datasheet
while (1){
delay_ms(250);
output_toggle (pin_A0); // accurate delay observed on this pin
printf ( "Hello World\r" ); //output message does not happen
} // do while end
} // main end
|
the SPEN and TXEN manipulation were required just to get the TX pin to go to the idle HI state , ( cribbed from the data sheet as well as SYNC)
PIN_A0 clock nicely at the expected rate.
This compiles under 4.141 and 5.005 -no errs or warns -
but neither version ever transmits any data from PIN B7
BTW: if i FORCE_SW and CLR tris B.7 - software transmit is possible
but useless in this application. the hardware support is simply not there!!
and YES been reported to CCS
bummer ........
Last edited by asmboy on Tue Jul 23, 2013 7:42 pm; edited 1 time in total |
|