PDA

View Full Version : Newbie here



FastEddie
- 13th August 2006, 05:11
Hi, I just got my PicBasic compiler last week, with an Epic programmer, so I'm pretty much brand new to this. I've been reading the posts on here and learning some good stuff. Anyways, I'm trying to figure out how to write to just a particular bit in a register. I'm using a 16F818 which has an internal osc. I' m trying to set the clock speed, so I used:

Write $8FE,%00010000

I only want to change bits 4, 5, and 6. The datasheet says that bit 2 is IOFS. I don't know what that is, or what the default setting is, so I'm trying to just change the bits that I want to and leave bit 2 at default. The others besides 2, 4, 5, and 6 are unused.

Thanks in advance for any help.

mister_e
- 13th August 2006, 11:31
PicBasic or PICBASIC Pro?

I guess you talk about OSCCON register @8F.. right?

you can't write to bit IOFS.. well you can but it will never do something.. it's a read-only bit. This bit tell you when the internal OSC frequency is stable.. not much

Let's say you want to set frequency to 8MHZ

PBP:
OSCCON=%01110000
OR if you want...
OSCCON.6=1
OSCCON.5=1
OSCCON.4=1

PicBasic... i can be wrong...
POKE $8F,%01110000

HTH

FastEddie
- 14th August 2006, 01:03
PicBasic
I think I tried that second example, and it wouldn't compile. But I'll try it again. Maybe I typed something wrong.
I did type it wrong, I tried your example and it compiled ok. I was typing in an h after the F.
Thanks.