Configure PIC24E to run at 70 MIPS

Setting the configuration bits

Macro for setting configuration bits must be placed somewhere at the top of the source file, right after the #include lines. For portability sake, I recommend this method rather than setting them in IDE.

Regardless of which clock source you will be using afterwards, the system is configured to use FRC at startup.


Next, use this macro for FRC case


and for the external crystal case


The latter is used for both cases in Microchip document. Consult the PIC24EPdatasheet and family reference manual for the meaning of each definition.

I/O Port Definitions

As shown in figure 1 above, only one input port (RB2) is used for the push-button switch, and one output port (RB15) for LED. Define them accordingly

#define SW1 !_RB2      // switch is active-low
#define LEDB  _LATB15  // blue LED 

Then put these lines in main() before the infinite loop, or in an init( ) function called by main.

ANSELA=0x0000;  // use all ports RA and RB as digital
_TRISB2 = 1;   // RB2 as input 
_CNPUB2 = 1;   // enable internal weak pull up
_TRISB15 = 0;   // RB15 as output

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s