Setup oscillator in mikroC for dsPIC

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Setup oscillator in mikroC for dsPIC

#1 Post by pwdixon » 09 Nov 2009 12:19

I'm having some problems understanding the project settings in mikroC for dsPIC.

I'm using a P33FJ256GP710 with a 10MHz crystal, I would like to run at 40MHz.

Can anyone post the settings required in the edit project form as I'm finding it hard to match the datasheet to the project settings.

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#2 Post by anikolic » 11 Nov 2009 11:13

Hi,
Well this is dependent on your project. You must specify what oscillator you are intending to use, how much memory do you want to occupy, do you use Watchdog timer, do you want to enable ICD debugger and so on. This will all be much much easier to configure in the upcoming mikroC PRO for dsPIC30/33 and PIC24 compiler that is expected to be released for beta testing by the end of November.

Best regards,
Aleksandar
Web Department Manager

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

#3 Post by pwdixon » 11 Nov 2009 14:42

I'm not using the watchdog or the debugger but how does my choice of oscillator affect the amount of memory used?

As for wait for the pro version, target delivery times are usually missed and I'm working on this now, also the pro version of the PIC compiler was quite different and required software mods and retest.

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#4 Post by anikolic » 12 Nov 2009 10:14

Hi,
My intention was to give you the complete list of all flags used and their settings, so I asked for this information, but it was clearly unnecessary, and I hereby apologize.
To enable PLL4x with 10MHz crystal = 40MHz do the following:
1. Go to Project->Edit Project
2. Under FOSCSEL section leave checked only:
a)_FNOSC_PRIPLL flag
b)_IESO_OFF flag
3. Under _FOSC section leave checked only:
a)_POSCMD_HS
4. Set Clock to 040.000000
5. Rebuild the project

Best regards,
Aleksandar
Web Department Manager

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

#5 Post by pwdixon » 12 Nov 2009 13:07

Thanks for the info.

I input those settings and my PIC does appear to be running, not sure what frequency its running at but now the serial ports don't work correctly.

I've seen some other posts suggesting that the serial init function does not set the baud rate correctly. I've tried using different settings for the BRG register but can't get the serial ports to work. Before changing the project settings I was able to run the serial ports although there did appear to be some odd limits on the baud rates that would work.

I'd like to run at 115200 Baud but so far even when it has worked I could only get port1 to run at 9600 Baud and port2 to run at 38400 Baud. I have not been able to get any baud rate to run with your project settings so far.

Can you give any guidance to exactly how to setup these ports with the project settings previously given?

Sobrietytest
Posts: 619
Joined: 05 Jul 2008 06:05
Location: Thailand

#6 Post by Sobrietytest » 18 Nov 2009 04:29

Hi, I run a PIC24 in the same oscillator configuration (10MHz + 4xPLL) with serial comms, despite the fact that you are using a 10MHz clock, you have to tell the compiler that the clock is 40MHz in the Project setup dialog on the left of the screen.

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

#7 Post by pwdixon » 18 Nov 2009 11:18

I already have the project clock set to 40MHz but I still can't get the serial ports to work at higher baud rates.

Sobrietytest can you post your config settings so that I can compare?

Sobrietytest
Posts: 619
Joined: 05 Jul 2008 06:05
Location: Thailand

#8 Post by Sobrietytest » 19 Nov 2009 03:46

Image

PIC24FJ128GA010. This is for an inclinometer and RTC data logger (SD). The project uses 2x SPI, 1x UART and 1x Soft_I2C. I'm running the UART at 115200 so that I can monitor the continuous data output on-screen and program the RTC from the Windows clock. This is quite an old project but I don't recall having any problems with the UART at the time.

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”