PDA

View Full Version : Help! PIC18 internal oscillator and CCS compiler?


stumax
Aug 01, 2006, 08:44 PM
Hi guys, I'm going nuts trying to get the internal oscillator of an 18F2331 to run at 8MHz instead of ~30kHz using the CCS compiler. There's a setup_oscillator( xxx ) command which is supposed to do it, however, when looking at the generated source code I can't see it writing the correct bits to the osccon register (0xFD3). The 18F2331.h file defines various oscillator options, such as frequency, which may be inserted in the () after the setup_oscillator() command, but it doesn't seem to make any difference. The PIC datasheet says to run at full speed bits 4-6 of osccon need to be set, but I can't see this happening in the listing. There's not much help available in the CCS manual regarding setting this up. Can anyone help? Thanks!

Stu.

stumax
Aug 01, 2006, 10:17 PM
I found the setup_oscillator() command just wasn't working, so I manually set the values for the osccon register by inserting:

#byte OSCCON = 0xFD3 at the start then

OSCCON=0x72; in main()

Now it seems to be working at 8MHz!

Stu.

ezflyr
Aug 02, 2006, 04:19 PM
Hi,

I know you've solved this particular problem, but in the future, I'd recommend the user forums on the CCS website. The likelihood of getting fast, accurate support fo the CCS compiler is much greater over there.

John

Gary Warner
Aug 02, 2006, 06:29 PM
I have no objection with his post here. I don't follow CCS's groups near as much as I these here. I learned something today.

Gary
--

stumax
Aug 03, 2006, 01:15 AM
John, I appreciate the advice - I actually wasn't aware that there was a forum for CCS. I checked it out and it looks OK. I barely have enough time to look at rcgroups these days, I certainly couldn't add another forum to the list of mega-time-occupying activities! The main reason I posted here is that the 18F2331 is specifically for BLDC use and I know a bunch of you guys may be trying it out for that purpose (like me), as well as the fact that for RC use, the internal oscillator is a real plus for removing a source of EMI.

BTW, if anyone else is trying to use the CCS compiler for BLDC apps with the PIC18Fxx31's, the power module commands don't work, timer5 commands don't work, the QEI input capture commands don't work and, of course, the internal oscillator commands don't work, even though all these commands are included in the relevent device.h file. Apart from all these things (and others) that don't work, I think the compiler is great.......

Stu.

ps2727
Aug 03, 2006, 01:30 AM
While I realize this isn't a dedicated PIC forum I like to see such posts as I am learning to use these devices and like to see the kind of problems guys run into, especially as it relates to RC use.

Keep posting here Stu, I'm watching and learning.......
Paul