Jump to content
43oh

organization of the pin numbers?


Recommended Posts

Hey, i'm having a little confusion about some things. This may be a dumb question, but here goes

 

I was looking at the blink Fade example, and it stated that it would use "Pin 9". I looked at the SPI example as well. I checked some of the documentation, online, and in the program, and it led me to Arduino documentation.

 

Can someone please let me know where i can find a good reference for the pins and the layout :). Thank you!

Link to post
Share on other sites

Pin numbering is according to the numbering of the header pins on the silk screen. Alternatively you can use predefined pin names:

P1_0, P1_2 .... P2_5. There are also defines for the LED's and button: RED_LED, GREEN_LED, PUSH2.

The table below can also be found in the file hardware/msp430/variants/launchpad/pins_energia.h. Link to this file on github: https://github.com/energia/Energia/blob ... _energia.h. Will put this up on the Wiki over the weekend.

 

 

                                  +-\/-+
                           VCC   1|    |20  GND
                     (A0)  P1.0  2|    |19  XIN
  *(TXD/RXD) (TA0.0) (A1)  P1.1  3|    |18  XOUT
  *(TXD/RXD) (TA0.1) (A2)  P1.2  4|    |17  TEST
                     (A3)  P1.3  5|    |16  RST#$
            *(TA0.2) (A4)  P1.4  6|    |15  P1.7  (A7)         (SCL) (MISO) depends on chip
             (TA0.0) (A5)  P1.5  7|    |14  P1.6  (A6) (TA0.2) (SDA) (MOSI)
                           P2.0  8|    |13  P2.5
                           P2.1  9|    |12  P2.4
                           P2.2 10|    |11  P2.3
                                  +----+

*(TA0.2): Only flavors with a comparator have TA0.2 on PIN 6
*(TXD/RXD): TimerSerial: P3 = TXD, P4 = RXD; Hardware Serial: P3 = RXD, P4 = TXD

Link to post
Share on other sites

So its even MORE useful! I really should take a look at those h files, i guess.

 

Which micros is will this work for? In other worse, if i have a Chronos, could it be used?

 

Is there a variable for the temperature sensor? :)

**Edit** see what i mean about that h file lol.

 

Many thanks! I will try out my own program later on tonight. My friends and i are trying ot do an experiment that calls for I2C later. Maybe you could show us how to set that up or port arduino libraries to it?

Link to post
Share on other sites

I'm now back to being confused. :), but much much less. This might be taken as simply a suggestion,

 

That pin out you gave was based on a 2553 i'm guess, and in' running a 2231. Pin 9 is the green LED, but it is 1.6, NOT 2.1. In that chart, 1.6 is 1.4Unless i'm mistaken, and i REALLY could be wrong, based on TI documentation, the pins only increase as the chip has the outputs, but always 1.0-1.7, then 2.0-2.7 and 3.0...etc. Do you think we can, just have pins 1.07-1.7 be pins 1 through 8, then 2.0-2.x be 9 through 9+x, and so on? That way, no matter what board or pin, you know that 2's are 9 and up, and so on? I might make some modifications to the header file, but i wonder if i could fry my board...

 

good news to report is that i made a servo move with PWM... although it was mad as all hell. Will start playing with the timers next :).

Link to post
Share on other sites

Yah, i'm feeling start contributing by helping write documentation and tutorials and stuff. I just want to wait until energia returns, have a long talk with him/her/them so i can get a deeper understanding of this while thing and some of the rationale. I'm honestly very VERY impressed and happy. I need to buy an oscilloscope better than my MyDAQ for sure....

 

I am now editig the h file. I think that the list below is a more universal pin out. It just shifts the pins into ascending input order instead of pin order. This way, we will always KNOW that pinMode(7,OUTPUT) will always make P1.0 an output, and pinMode (19, INPUT) will always make P2.4 an input, no matter the board. My F2012s are shipped so when i get them i can do a further study, but i do want to know if simply editing that h file will make all the necessary changes to the layout, or is there another place i should also look :)?

 

Get the standard pins out of the way

1. VCC

2. GND

3. Reset

4. Test

5. Xin

6. Xout

 

Now start the normal sequence of pinouts, with the if statements with whatever conditionals neccessary

7. P1.0

8. P1.1

9. P1.2

10. P1.3

11. P1.4

12. P1.5

13. P1.6

14. P1.7

15. P2.0

16. P2.1

17. P2.2

18. P2.3

19. P2.4

20. P2.5

21. P2.6

22. P2.7

23. P3.0

24. P3.1

25. P3.2

26. P3.3

27. P3.4

28. P3.5

29. P3.6

30. P3.7

 

And so on...

 

thoughts?

Link to post
Share on other sites

The whole pin number thing makes me crazy. The way the arduino code was done, it requires runtime code to figure out something that is typically known at compile time. I would rather see the pin to port/bitmask mapping determined at compile time so code space and processing isn't wasted on this task. However, that isn't going to happen.

 

However, there is already a solution to deal with the pin numbers so humans can read them. In pins_energia.h there

are static constants that map the P1_0 names to pin numbers. If you use these variables, your code will be self

documenting and make better sense.

 

// Pin names based on the silkscreen
//
static const uint8_t P1_0 = 2;
static const uint8_t P1_1 = 3;
static const uint8_t P1_2 = 4;
static const uint8_t P1_3 = 5;
static const uint8_t P1_4 = 6;
static const uint8_t P1_5 = 7;
static const uint8_t P2_0 = 8;
static const uint8_t P2_1 = 9;
static const uint8_t P2_2 = 10;
static const uint8_t P2_3 = 11;
static const uint8_t P2_4 = 12;
static const uint8_t P2_5 = 13;
static const uint8_t P1_6 = 14;
static const uint8_t P1_7 = 15;

 

To use these variables, just use something like digitalWrite(P1_0, HIGH); I think this makes a lot more sense than some pin number scheme I have to root around in the documentation to find. Or worse, a pin number scheme that keeps changing so that old code that relied on numbers is now wrong because the pins number scheme changed arbitrarily.

 

Please don't go messing with the pin numbers just for the sake of changing them.

 

-rick

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...