5
\$\begingroup\$

I see a lot of sample code and tutorials, but where is it documented that symbols (defines) such as P1OUT and P1DIR are available and what are their semantics?

I see a list with one-phrase comments in the header files, but that's the same as browsing through source code. I am looking for a technical document: an API reference or at least a Programmer's Guide.

\$\endgroup\$
6
  • \$\begingroup\$ @Passerby yes, i rarely cross-post. happy to delete the other one, but at the moment it seems harmless and might help somebody stuck in my situation. \$\endgroup\$ Jul 14, 2014 at 3:55
  • \$\begingroup\$ @necromancer Yes cross-posting is frowned upon. Rationale here. Deleting the copy on StackOverflow makes sense. \$\endgroup\$ Jul 14, 2014 at 4:01
  • \$\begingroup\$ @NickAlexeev Thanks for pointing it out. I would, but there is a nice answer there, and I would prefer to be frowned upon than delete the answer, not the least to be respectful of the answerer's effort. Hopefully we can tolerate an exception. The folks at SO are really gung-ho on closing, and it seems they tried but fell short of the necessary votes. That means multiple people felt it was OK (despite the cross-posting disclosure I posted there). Hope we can let it be, or perhaps migrate the answer here? \$\endgroup\$ Jul 14, 2014 at 4:09
  • \$\begingroup\$ @necromancer If you look closely, you'll notice that cde on SO and Passerby on EE.SE is the same person. He provided roughly the same answer in both places (although, the version here on EE.SE is better). So, if SO thread is deleted, then information is not lost. \$\endgroup\$ Jul 14, 2014 at 4:15
  • \$\begingroup\$ @NickAlexeev thanks, no wonder they sounded similar. I tried to delete but could not because it has answers. I flagged it for moderator attention and requested a delete mentioning that the answer has been captured here. \$\endgroup\$ Jul 14, 2014 at 4:19

3 Answers 3

3
\$\begingroup\$

The names of these defines match the names of the registers. The registers can be looked up in the datasheet for you model of MSP430 or in the family user guide. For instance, in case of MSP430FR5739 (1) the P1OUT and P1DIR are described section 8.4 of its family user guide (slau272b).

(1) Nothing special about it. Just the closest one to me at the moment of writing.
(2) P1OUT and P1DIR are just register names. Nobody calls them API in the [under]world of low level programming.

Also, find the place where they are defined in the source code. There may be comments.

The datasheet and the family user guide (when there is one) are required reading. You have to read them, or at least skim through them. There is no excuse for not reading them.

\$\endgroup\$
1
  • \$\begingroup\$ +1 thanks, this is very useful to know as i enter this brave new [under]world :) \$\endgroup\$ Jul 14, 2014 at 3:51
4
\$\begingroup\$

These are defined in the includes. For CCS, the default is the TI created msp430.h, which then attempts to include the specific file for your target device through if defines. That file (i.e. msp4430g2553.h) is which houses the specific references like P1OUT or P1DIR matching to the specific register address as defined in your Target Device's Datasheet and Family guide. For the most part, the names should match the Family Guide, and are very consistent between devices.

From the CCS User Guide:

Use .h files to simplify code development.

CCS is supplied with files for each device that define the device registers and the bit names. Using these files is recommended and can greatly simplify the task of developing a program. To include the .h file corresponding to the target device, add the line #include for C
and .cdecls C,LIST,"msp430xyyy" for assembly code, where xyyy specifies the MSP430 part number.

Here is an online copy of the msp430g2553.h from CCS. Very well commented and easy to read.

IAR, as well as having the msp430.h versions, also includes io430.h, which is created by IAR and has a few differences or additional features. It also acts the same way of including the specific target device's header.

\$\endgroup\$
2
  • \$\begingroup\$ thanks again @Passerby the excerpt from the CCS User Guide is esp. authoritative \$\endgroup\$ Jul 14, 2014 at 3:52
  • \$\begingroup\$ after much consideration, since both answers are quite similar, selecting the older answer as the correct one. difficult choice between this awesome answer and the other one. i'm glad i could not delete the SO question, since i've accepted your answer there. thank you again! \$\endgroup\$ Jul 16, 2014 at 9:39
1
\$\begingroup\$

Yes, an API does exist. They are referred to as driverlib. Download code composer studio, then install MSP430ware, and you can look into details of the driver library.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.