element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Newbie Question about Status and Control Registers on Uno
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 3 replies
  • Subscribers 401 subscribers
  • Views 323 views
  • Users 0 members are here
Related

Newbie Question about Status and Control Registers on Uno

grovesr
grovesr over 13 years ago

Hi,

I am somewhat new to microcontrollers and am just getting to the point where I am starting to mess around with the timer registers.  I have learned how to use the CTC features to generate divided clock outputs.  In doing this I discovered that the changes that I made to the timer control registers seem to be persistent, when I load in a new program using the Arduino IDE.  I had assumed that whenever I loaded in a new program, the control registers would be reset to some default initial state (i.e. all "0").  Am I correct that the timer control registers do not get reset when loading in a new program?

 

I am currently forcing the timer control registers back to an initial "0" state at the top of my program before I start setting the bits I want to play around with.  I am mainly asking because I have never seen any other code example where the control registers get reset to "0" at the beginning, and I am wondering if I am perhaps doing something wrong.

 

Thanks.

  • Sign in to reply
  • Cancel
Parents
  • DAB
    0 DAB over 13 years ago

    Hi Robert,

     

    I am not fully conversant in Arduino code, but in general an MCU will have some default state for all registers.  Usually they are set to a state where no bad things happen when the MCU powers up and begins loading the boot code.  So if you have code or definitions that setup the control registers, then that is what you will see when you turn it on.

     

    Usually a control register is write only, though I have seen MCU's where you could indeed read the current control states.  If you want to test this feature, set up a loop where you cycle each bit in the register on and off.  Set up your debug to monitor the registers and see what happens.

     

    Hopefully someone who knows the Arduino better than I can tell you for sure.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • grovesr
    0 grovesr over 13 years ago in reply to DAB

    Thanks for the response DAB.

     

    I guess I'm most interested in what happens on uploading my program to the Arduino.  Do the registers all get defaulted to some initial state, then my code is loaded and run, setting the new register bits as I desire?  Or do the registers retain their previous values and any bit-by-bit setting of registers done in  my code are additive to the previously saved state?  My understanding is that the control registers map to locations in the Flash memory, so I think they should retain their information.

     

    It's just a question of what is the initial state of the registers immediately after uploading my code, and before actually running my code?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • grovesr
    0 grovesr over 13 years ago in reply to DAB

    Thanks for the response DAB.

     

    I guess I'm most interested in what happens on uploading my program to the Arduino.  Do the registers all get defaulted to some initial state, then my code is loaded and run, setting the new register bits as I desire?  Or do the registers retain their previous values and any bit-by-bit setting of registers done in  my code are additive to the previously saved state?  My understanding is that the control registers map to locations in the Flash memory, so I think they should retain their information.

     

    It's just a question of what is the initial state of the registers immediately after uploading my code, and before actually running my code?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube