energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
794 stars 672 forks source link

CC3200 - analog read examples do not work - define analog input pins A0, A1, etc #483

Closed ecdr closed 10 years ago

ecdr commented 10 years ago

The examples that use analog input do not work on CC3200. For instance Examples - Analog - AnalogInput

Fails because the Arduino style names for the analog input pins (A0, A1, etc.) are not defined.

Suggest add to hardware/cc3200/variants/launchpad/pins_energia.h (up near where RED_LED, etc. are defined)

static const uint8_t A0 = PIN_57; static const uint8_t A1 = PIN_58; static const uint8_t A2 = PIN_59; static const uint8_t A3 = PIN_60;

(Or possibly in a different order, e.g. put them in order by Energia pin number A0 = PIN_58, A1 = PIN_59, A3 = PIN_57 and A4 = PIN_60)

Of course the CC3200 documentation sometimes refers to the I/O ports by names A0, A1. However those names are not used in Energia, so this should not cause conflicts. (Could make the ports PA0, PA1, similar to on Tiva LP.)

Thanks.

rei-vilo commented 10 years ago

Please don't use the PIN_57 naming scheme but the pins numbers instead, e.g. 2.

Note that only the updated pins map only mentions the pins numbers.

cc3200 launchpad pins maps

ecdr commented 10 years ago

pins_energia.h uses both numbering schemes. It is not obvious which one is preferred in that context. It seems less ambiguous to use the PIN_xx names there, since they are unique (whereas there are multiple Energia pin numbers which refer to the same PIN_xx, so more care is required when using them.)

Whichever naming scheme is preferred for the fix, this is still a Bug in Energia (i.e. it will not compile the examples that come with the environment).

Suggest add to hardware/cc3200/variants/launchpad/pins_energia.h (up near where RED_LED, etc. are defined)

static const uint8_t A0 = 23; static const uint8_t A1 = 2; static const uint8_t A2 = 6; static const uint8_t A3 = 24;

(Or possibly in a different order, e.g. put them in order by Energia pin number A0 = 2, A1 = 6, A3 = 23 and A4 = 24)

Alternative solution - explain in the documentation that analog pin names do not exist for this platform. (e.g. on Guide_CC3200, and on tutorial material about analog read, etc.)

rei-vilo commented 10 years ago

I know, but an engineer from TI explained me there were incompatibilities between the different naming schemes: pin number of the MCU, pin name, pin referenced in TivaWare, etc. and asked me to keep the LaunchPad pins numbers only.

That's why I've removed the version with the pins names, to avoid any misunderstanding.

I hope next LaunchPads will have a better and cleaner implementation for the pins naming schemes.

Please use the LaunchPad pins numbers —white in black in the pins map.

ecdr commented 10 years ago

As an addition to the fix I suggested here, suggest changing analogRead function in wiring_analog.c to use the above defined A0, etc. constants, rather than the PIN_xx constants (as it does now).

Then they will still be connected by symbols (rather than values), and it will help in moving away from the PIN_xx numbers.

Or are you saying that the use of all other pin names (including the Arduino traditional A0, A1, etc. for analog pins, which has nothing to do with TI's pin names) is being discouraged?

JohnRDOrazio commented 9 years ago

White in black in the pins map shows pin 12 (in the P2 column) as a digital pin (green code = digitalRead + digitalWrite). However pinMode(12, OUTPUT) + digitalWrite(12, HIGH) does not turn on a LED on pin 12 (P55 on the board). Pins 2-11 work just fine, I can turn on a LED with each of these, but no other numbers from 12 on seem to work. And yet, according to the pin scheme, there is a green code next to pins 12, 14, 15, 17, 18, 19, 23, 24, 27, 28, 30, and 32. Shouldn't I be able to digitalRead / digitalWrite on each of these pins too?

JohnRDOrazio commented 9 years ago

I correct my previous remark, I now understand that pin 12 is used by FTDI so you have to move the jumper on J7 down one pin in order to be able to use pin 12. But I see that all other digital pins are working just fine (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 23, 24, 27, 28, 30, 31, 32).

rei-vilo commented 9 years ago

Yes, pins in faded colours like 13 25 26 33 34 35 36 37 38 39 40 mean they are not available or they are optional. Most of them are already used.