PDA

View Full Version : Clock Question - New to PicBasic



cometboy
- 1st November 2006, 21:06
I just bought a copy of PicBasic ( the cheap model ) and have completed the blinking LED exercise. I'm using the EPIC programmer. I'm having a speed problem though.

The LED is flashing about an order of magnitude slower than expected (clock problem). So it looks like the clock is set to 400KHz rather than 4MHz.

I'm using a 16F819 without an external crystal. I'm using the INTRC command in the configuration section of the EPIC software.

I guess that there is a DEFINE OSC command, but as far as I can tell, its only for PicBasicPro.

Do I have to add a crystal to the circuit? I wanted to minimize parts count, so that is not an attractive option.

Do I have to buy the premium Pro program to run my first stupid project? I sure hope not.

My long term goal is building RGB LED clusters using PIC chips driving a NXP PCA9633 LED driver. All will be done using i2c. I have what I want running using the PicAxe system of chips (18X), but was hoping to migrate to PIC by using PicBasic.

Thanks.

paul borgmeier
- 1st November 2006, 23:26
The 819 has the ability to be run at several different clock speeds when using the internal oscillator option. Did you set up the OSCCON register? If not, take a look at the 16F819 data sheet, section 4 for details. Post back if you need more information.

cometboy
- 2nd November 2006, 23:43
Paul,

I got some time to look around following your advice, searched to forums for OSCCOM. Quikly found out that it was a non-PicBasic command.

A hour searching the 16F819 data sheet got me the command, the address and the register description.

The command POKE $8F, %01100000 got me 4MHz and a correct blink rate.

I guess I'm going to have to learn some assembly whether I want to or not.

Thanks for the lead.

I'm hoping that I'll have better luck with PicBasic (ie using it as a high level language, rather having to hunt around for register addresses). If I end up doing too much assembly level crap, it will kind of defeat the purpose of using PicBasic. We shall see.....

Alan

paul borgmeier
- 3rd November 2006, 00:39
Alan,

Nice work! - With PBC, you need to find and deal with register addresses like you did. With PBP, you do not (as much). Again, good job.