Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can TESTMODE pin 33 (PA8) on P1 be used as an extra P1S6 pin? #1059

Closed
technobly opened this issue Jul 11, 2016 · 2 comments

Comments

@technobly
Copy link
Member

commented Jul 11, 2016

It looks like this pin was overlooked as a useable pin, given that it's name was indicated as TESTMODE it was deemed a reserved pin.

A new pin P1S6 - 30 definition would have to be added here:

https://github.com/spark/firmware/blob/develop/hal/src/stm32f2xx/pinmap_hal.c#L103

A definition here:

https://github.com/spark/firmware/blob/develop/hal/inc/pinmap_hal.h#L161

And TOTAL_PINS bumped to 31 for P1 here:

https://github.com/spark/firmware/blob/develop/hal/inc/pinmap_hal.h#L77

That should allow use of pinMode(P1S6, OUTPUT) and digitalWrite(P1S6, LOW)

This should ensure the pin gets set as an INPUT floating by default. change to pin<=30

https://github.com/spark/firmware/blob/develop/hal/src/stm32f2xx/core_hal_stm32f2xx.c#L314-L315

Since a TIM1_CH1 is on PA8, we will want to explore all of the timer based peripherals this may affect as well (PWM, Tone, Servo, Gen purpose timers, etc..)

The P1 datasheet would need to be updated as well, or at minimum an issue logged to update it.

Completeness:

  • Minimum test case added
  • Device, system and user firmware versions stated
  • Particle confirmed

@technobly technobly added this to the 0.7.x milestone Jul 11, 2016

@technobly

This comment has been minimized.

Copy link
Member Author

commented Jul 12, 2016

Added above:
This should ensure the pin gets set as an INPUT floating by default. change to pin<=30

https://github.com/spark/firmware/blob/develop/hal/src/stm32f2xx/core_hal_stm32f2xx.c#L314-L315

@technobly

This comment has been minimized.

Copy link
Member Author

commented Jul 13, 2016

After a deeper dig in implementing the above changes. Using this application:

#include "application.h"

void doit() {
    pinMode(P1S6, OUTPUT);
    digitalWrite(P1S6, LOW);
}

STARTUP(doit())

void setup() {
    doit();
}

void loop() {
    digitalWrite(P1S6, !digitalRead(P1S6));
    delay(1000);
}

it appeared that WICED was re-initializing this pin again since STARTUP() will run right at boot. I looked all over and finally tracked it to some initialization code in WICED that appears to use this pin in its alternate function MCO1 as the Main Clock Output 1 which is connected to the LSE (32kHz) oscillator. When you look at the pin on a scope, it's not 1.65V... it's a 50% DC squarewave oscillating at 32kHz. WICED uses this pin as a clock for powersave mode. Wi-Fi Powersave Mode is not enabled by default, and when taking over this pin as a GPIO it doesn't appear to crash the Wi-Fi which is further validation that it's not currently used. However it's most definitely hooked up as a standby clock source. For documentation sake, the WICED function called is host_platform_init_wlan_powersave_clock(). You won't find that in our source, it's only in WICED source code. To get the functionality desired, we'd have to modify the WICED stack to make this alternate function initialization disabled by default, and only enabled when powersave mode is also enabled. The pin should probably only then be used as a GPIO, and any transients or ESD on this pin could be fatal to the BCM (Wi-Fi chip). So it's not looking likely that we'd want to enable this pin as a GPIO, but if someone can't live without this pin, and they won't ever want powersave mode... it seems possible to use it. Some more investigation would be required to figure out for sure what this hooks up to on the BCM chip.

@technobly technobly removed this from the 0.7.x milestone Jul 13, 2016

@technobly technobly added this to the 0.7.x milestone Sep 9, 2016

@technobly technobly self-assigned this Sep 9, 2016

@technobly technobly closed this Nov 29, 2016

@technobly technobly removed their assignment Nov 29, 2016

@technobly technobly modified the milestones: 0.7.x, 0.6.1 Nov 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.