Get Adobe Flash player
FacebookTwitterGoogle+
English Arabic French German Italian Portuguese Russian Spanish

Did you know?

The word engineering is derived from the Latin word ingeniere which means ingenious.
 

Help us stay online:

small donate

blinkledIn this example  RB4, RB5 and RD0 pins are used as digital output pins. These pins can be used as general purpose output pins (GPIO pins) to drive LED diode directly or as TTL level signal output. Complete source code programmed in dsPic C30 compiler with MPLAB project files is provided and every line has comments with detailed explanation.

 

 

 

Description of task: Pins RB4,RB5 and RD0 toggle their state.

#include<p30fxxxx.h>
_FOSC(CSW_FSCM_OFF & XT_PLL4);//frequency of instruction tact is same as frequency of crystal 
_FWDT(WDT_OFF);
unsigned int broj1,broj2;
void main(void)
       {
           ADPCFGbits.PCFG4=1;//configures pin B4 as digital
           ADPCFGbits.PCFG5=1;//configures pin B5 as digital
           TRISBbits.TRISB4=0;// configures pin B4 as output
           TRISBbits.TRISB5=0;//configures pin B5 as output
           TRISDbits.TRISD0=1;//configures pin DO as output
            while(1)
                     {
                           for(broj1=0;broj1<700;broj1++) //pause
                           for(broj2=0;broj2<300;broj2++);
                           LATBbits.LATB4=~LATBbits.LATB4;//inverts pin B4
                           LATBbits.LATB5=~LATBbits.LATB5;//inverts pin B5  
                           LATDbits.LATD0=~LATDbits.LATD0;//inverts pin B5
                           for(broj1=0;broj1<700;broj1++)//pause
                           for(broj2=0;broj2<300;broj2++);
 
                    }// while
      }//main

Complete project and source code can be downloaded here.