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

16f628 example please

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



Joined: 21 Jan 2004
Posts: 15
Location: Argentina

View user's profile Send private message

16f628 example please
PostPosted: Wed Jan 21, 2004 9:46 am     Reply with quote

I need something easy to start with for the 16f628: a sample programm turning on and off an output and sending a message to the rs232 port. I'm missing something important that don't let me do any of these things. I already tryed with some lines I used for the 16f84 that were running but with the 16f628 don't work. I should be easer since this chip includes an USART but nothing works.
any help will be welcome !
tks
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Wed Jan 21, 2004 4:30 pm     Reply with quote

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!
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