| rwyoung 
 
 
 Joined: 12 Nov 2003
 Posts: 563
 Location: Lawrence, KS  USA
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Wed Jan 21, 2004 4:30 pm |   |  
				| 
 |  
				| The following should work. Assumes 4MHz crystal (HS oscillator mode).
 RS232 stream has been named "OUT232" in case you want to try adding a second RS232 software port.
 I/O pin defalts to the #use standard_io() method where the compiler is generating code to set the TRIS bit each time it changes the pin state.
 
 Code came from test code used on CCS's 16F877 board but I've changed the header and pin assignments to comply with the 16F628.
 
 
  	  | Code: |  	  | #include <16f628.h>
 
 #fuses HS, NOLVP, NOWDT, PUT
 #use delay (clock=4000000)
 #use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,stream=OUT232)
 
 #define LED PIN_A1
 
 void main(void)
 {
 while(TRUE) {
 fprintf(OUT232, "\r\nON");
 output_low(LED);
 delay_ms(1000);
 fprintf(OUT232, "\r\nOFF");
 output_high(LED);
 delay_ms(1000);
 }
 }
 
 | 
 _________________
 Rob Young
 The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
 |  |