Header for PIC16F688 with C-Compiler

Guest #3155185
Hi, first of all: I´m new to coding for PICs. I´m trying to code my very 
first programm in C. I´m using MPLAB IDE v8.90 with HI-TECH ANSI 
C-Compiler.
I used to code some minor programms in Java so I decided to code in C. 
Assembler seems very difficult to me. So my question is. I want to 
configure my PIC16F688 with internal clock so that it lights up and 
blinks a LED. The coding is not the biggest problem. My problem is the 
configuration of the PICs Pins (include/header). I hope you guys can 
help me with this and give me an advices and maybe a description what to 
do.
Guest
Use GOOGLE to look for example projects and learn from them!

  "PIC16F688" project  "Hi-tech" Compiler
  "PIC16F688" project  "Hitech" Compiler

  "PIC16F688" project  "Hi-tech" Compiler mcp "source code"

regards
Thank you for the quick answer.
I already used google but I cant find anythig which helps me. I just 
need to configure the pins and how to implement them in code and how to 
set up the clock

Edit: or can you recommend an other IDE or programming tool?
Guest
Ok real quick:

It seems like you're actually trying, unlike a few other posts I've seen 
here where the OP is basically asking for someone to design a complete 
board for them with very little information.

The OSCCON register sets the internal clock frequency.  Just worry about 
bits 6 through 4.  The others shouldn't matter.

Next you have to config the pin connected to the LED as an output.  Say 
you want to use pin 8; you'd have to clear bit 2 of TRISC since pin 8 is 
bit 2 of port C.  The bits in a TRIS register must be cleared to make it 
an output, and set to make it an input (think 1 for input, 0 for 
output).

Sometimes there's a register that configs a pin for use with the A/D, or 
as a digital pin.  I don't see it on this chip.

As for the configuration bits (what is set in MPLAB, page 111 of 
datasheet), make sure the watchdog is disabled for now, WDTE, and set 
FOSC to binary 100.  That sets it to use the internal oscillator.  Make 
sure the MCLR pin is pulled to +5 so it doesn't get stuck in reset.

As for the format of how to write to these registers, look at some 
examples provided with HITECH.  I don't recall how that one works.  You 
could take a look at my website.  I have some example code on there for 
other PICS.  Actually, now that I think about it, I believe the single 
digit clock I have there uses the 688.

http://users9.nofeehost.com/jmiller/

Reply

A question of your own? This thread is over 13 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.