Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 4922

Timer code for PIC18f to toggle led for 1 second

$
0
0
Hi All,

I am facing issue in toggling led for 1 second using timer0,
led is connected to RB7 of PIC18f.
Though i can insert delay_ms(1000); and toggle led i wish to do it using timer and interrupt.



Here is my code :

#code
Code (Text):
  1. void main()
  2.   {
  3.   ADCON1 = 0x0F;  // Disable Analog functions
  4.   ANSELA=0;
  5.   ANSELB=0;
  6.   TRISB = 0x00;
  7.   PORTA = 0x00;
  8.  
  9.   T0PS2_bit = 1;     // 256 prescalar
  10.   T0PS1_bit = 1;
  11.   T0PS0_bit = 1;
  12.   PSA_bit    = 0;       // source from FCPU 5MHz
  13.   T0CS_bit   = 1;...
Timer code for PIC18f to toggle led for 1 second

Viewing all articles
Browse latest Browse all 4922

Trending Articles