Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3272476
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:49:48+00:00 2026-05-17T18:49:48+00:00

I am new to Embedded Programming, taking courses on it. And working with ATSTK600.

  • 0

I am new to Embedded Programming, taking courses on it. And working with ATSTK600.

I am looking for some help on “how to write header files for Devices”. Well, to be specific, what are the standard to be followed while writing header files like naming a register, etc (how to create .h & include, that I know).

Recently, I got an assignment to create a header file which I did, was on right track with some mistakes to be corrected before re-submission. While defining USART (made a mistake as this is very new to me)

#define USART_RX $0032 [which professor said is wrong because of $ sign #define will not work]. So is the following definition correct?

#define USART0_RX  32
#define USART0_UDRE  34
#define USART0_TX  36

Another thing is I defined ports as following, is this correct naming convention?

#define I_PINS_PORTA  0x20
#define DD_PORTA  0x21
#define DATA_PORTA  0x22

Well, somewhere I read the proper naming convention is #define BASE_ADDR_PORTA 0x20 but then what should be used for DD_PORTA & I_PINS_PORTA?

I was looking for some help on this over the web & came across this forum.

P.S. AM using C as a programming language.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:49:48+00:00Added an answer on May 17, 2026 at 6:49 pm

    One convention that you seemed to have followed for the UART, but not for PORTA is to put the system’s name at the beginning of the name. It makes it easier to spot in code. So rather than

    #define DD_PORTA 0x21
    

    you might have

    #define PORTA_DD 0x21
    

    Using base addresses for devices that span a region of registers is also a good idea. To do this you would have:

    #define PORTA_BASE 0x20
    
    #define PORT_I       0x00
    #define PORT_DD      0x01
    #define PORT_DATA    0x02
    
    #define PORTA_I     (PORTA_BASE + PORT_I)
    #define PORTA_DD    (PORTA_BASE + PORT_DD)
    #define PORTA_DATA  (PORTA_BASE + PORT_DATA)
    

    This ends up being more typing but it helps you avoid mistakes later.

    Different people and companies have their own preferences on how things like this are named and their interfaces, so there is no perfect answer.

    As far as byte alignment — I’m not sure what you are asking about it. The alignment of a memory address has to do with the remainder of the address divided by the alignment size (in bytes) being 0. Many systems can either only load and store at addresses evenly divisible by 2, 4, or 8 (or do so much more quickly to addresses that meet the requirement). Additionally, CPU cache performance is effected by alignment (having some needed memory only half in cache may be as bad as not having it at all).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My new project is targeting an embedded ARM processor. I have a build system
How does one dynamically load a new report from an embedded resource? I have
New to xml. Looking for XPath to search a xml file with python ElementTree
New to Linux programming in general. I am trying to communicate with a kernel
New class is a subclass of the original object It needs to be php4
New to javascript/jquery and having a hard time with using this or $(this) to
New to silverlight. Traditionally if I were to design a wizard-like process where a
New to both Ruby and Rails but I'm book educated by now (which apparently
New to WCF, but familiar with COM+ - can I wrap a WCF service
The new extensions in .Net 3.5 allow functionality to be split out from interfaces.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.