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

16f1509 no apparent RS232 support [solved]

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



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

16f1509 no apparent RS232 support [solved]
PostPosted: Tue Jul 23, 2013 4:26 pm     Reply with quote

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
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jul 23, 2013 7:41 pm     Reply with quote

got it working in 5.005 Evil or Very Mad Evil or Very Mad Evil or Very Mad
chipedit
tell the compiler where the Twisted Evil Twisted Evil
RX TX pins really are Crying or Very sad
SPEN,TXEN,SYNC not needing to be set any more either
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