EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / Timer0 PIC16F917

Timer0 PIC16F917

|

Microcontroller › PIC › Timer0 PIC16F917

  • This topic has 0 replies, 1 voice, and was last updated 9 years, 7 months ago by Dragu Mircea.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • December 29, 2012 at 8:32 pm #3909
    Dragu Mircea
    Participant
    Hy.I am a beginner in programming microcontroller. I use PIC16F917 microcontroller.I made a program who must realize the next tasks :
     
    – Led D0 stay ON 3 second
    – Led D0 goes OFF and remain in these state 3 second.
     
    My program :
     
      #include<pic.h>
     
      int count = 0;
      int main()
      {
          TRISD = 0b01111111;      // RD7 – output
          TMR0 = 0;                         // Timer register is reset
          T0CS = 0;                          // Work with internal CLK
          T0SE = 0;                          // Reacting on Low to High edge
          PSA = 0;                            // Work with a prescaler
          PS0 = 1;
          PS1 = 1;
          PS2 = 1;                             // Prescaler value divides in 256
          while(1)
          {
              PORTDbits.RD7 = 1;     // D7 pin is ON
              while(!T0IF);                   // Stays here 256 times and then T0IF=1
              T0IF = 0;                        // Reseting the overflow flag
              count++;                          // Increasing by 1
              if(count == 46)
              {
                   count = 0;                   // When count reaches 46 – reseting to 0
               }
              PORTDbits.RD7 = 0;
              while(!T0IF);       
              T0IF = 0;           
              count++;            
              if(count == 46)
              {
                   count = 0;       
              }
        }
    }
     
    Thank you.
    With respect Mircea.
  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Charging shutdown circuit question. August 7, 2022
  • Pedestal fan August 7, 2022
  • Beam Break Sensor August 7, 2022
  • Right channel distortion on vintage fisher rs-2010 August 7, 2022
  • Class AB amp help. August 6, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools