• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How do i set the PIC processor frequency for MPLAB?

Status
Not open for further replies.

GraveYard_Killer

New Member
im using C for programming PIC. but yesterday I wanna try something new and program PIC using assembly language. and im totally new with the use of MPLAB so forgive me for my following stupid questions. :)

my question is, how do i set the PICs processor frequency in MPLAB (im using PIC16f84a and a 10.24MHz Crystal Osc) to be burned in hex file? do i need to specify the PICs processor frequency to be used? i saw the tutorial that PICs processor frequency was set in the MPLAB SIM? thanks.
 

Jay.slovak

Active Member
You don't have to specify PIC Frequency in HEX file, just set the required crystal mode (LP, XT, HS) in configuration bits... If you plan to use MPLAB SIM to debug, you can set your frequency in "Debbuger/settings".
 

GraveYard_Killer

New Member
You don't have to specify PIC Frequency in HEX file, just set the required crystal mode (LP, XT, HS) in configuration bits... If you plan to use MPLAB SIM to debug, you can set your frequency in "Debbuger/settings".
thanks for the reply. i didnt thought of being as simple as that and i almost halted learning MPLAB because of this one. :)

i tried the Wiz C Demo, and im wondring why do i need to input the frequency before I compile it? Is it because the it will adjust the timing for the Wait delay C functions? thanks
 

Jay.slovak

Active Member
I can't help you with C... I use assembly, I like to have full control over the PIC...
But it sound resonable to enter frequency before compiling C (because of its higher level architecture).
 

GraveYard_Killer

New Member
ic. btw thanks. i appreciate your help. :D

i can now resume doing sample programs with MPLAB. Many thanks. :wink:
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Jay.slovak said:
I can't help you with C... I use assembly, I like to have full control over the PIC...
But it sound resonable to enter frequency before compiling C (because of its higher level architecture).
Yes, you will have to tell a high level compiler what clock frequency you're using, so it can adjust it's timing functions accordingly.

You have to do the same basic thing in assembler as well, except it's not as simple as that - YOU have to rewrite any time critical functions for the new clock speed.
 

johnny91

New Member
checking time

hi,
can someone please explain how I can check delay time using MPLAB SIM using delay functions ?
thanks.
my code is here :

#include <p18f4550.h>
#include <delays.h>

#pragma config FOSC = HS //Internal oscillator, port function on RA6, EC used by USB
//#pragma config PLLDIV = 1 //Divide by 2 (8 MHz oscillator input)
#pragma config WDT = OFF //Disable watchdog timer

//#define LEDPin LATBbits.LATB7 //Define LEDPin as PORT B Pin 1
//#define LEDTris TRISBbits.TRISB7 //Define LEDTris as TRISB Pin 1

void main()
{
ADCON1 = 0x0F; // Configure all ports with analog function as digital
CMCON = 7; // Disable comparators
//LEDTris = 0;//Set LED Pin data direction to OUTPUT
//LEDPin = 1;//Set LED Pin
TRISB = 0;
PORTB = 0;


while(1)
{
/* Reset the LEDs */
PORTB = ~PORTB;
//LEDPin = ~LEDPin;//Toggle LED Pin
Delay10KTCYx(24);//Delay 250K cycles (1 second at 1MHz since each instruction takes 4 cycles)
/* Light the LEDs */
//PORTB = 0xFF;

}
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading

 
Top