BLINKING USING DSPIC30F2010 USING MIKRO C

C LANGUAGE


LED BLINKING AT PIN E0
//i have used crystal of 16 MHz

void main()
{
TRISE.F0=0;
  while (1)
  {
PORTE.F0=1;
Delay_ms(1000);
PORTE.F0=0;
Delay_ms(1000);

  }
}




LED BLINKING USING TIMER REGISTERS

//i have used crystal of 16 MHz
void main()
{
PORTE = 0x0000;
TRISE.F0 = 0;
T1CON = 0; //Turn off Timer1 and clear settings
TMR1 = 0; //Start Timer1 at zero
PR1 = 10000; //Set period register value
T1CON = 0x8030; //Turn on Timer1 with 1:256prescaler
//T1CON = 0x8020; //Turn on Timer1 with 1:64prescaler
// T1CON = 0x8000  //Turn on Timer1 with 1:1prescaler --ABOVE 500KHz
//T1CON = 0x8010; //Turn on Timer1 with 1:8prescaler
while (1)
{
while(!IFS0bits.T1IF); //Wait for timer period
IFS0bits.T1IF = 0; //Clear timer flag for next period
PORTE.F0 ^= 1; //Toggle LED
}
}


PASCAL LANGUAGE


BLINKING PORTE



program BLINK
main:
TRISE=0
while TRUE
LATE=0
Delay_ms(500)
LATE=0xff
Delay_ms(500)
wend
end.

BLINKING SINGLE PIN RE0 IN PORTE



program BLINK
main:
TRISE.0=0
while TRUE
LATE.0=0
Delay_ms(500)
LATE.0=1
Delay_ms(500)
wend
end.

BLINKING SINGLE PIN RE0 IN PORTE (PIN DECLARED METHOD
)

program BLINK
dim LEDRED as sbit at LATE1_bit

main:
TRISE.1=0
while TRUE
LEDRED=0
Delay_ms(500)
LEDRED=1
Delay_ms(500)
wend
end.