10000 Pin drive strength is not the same V1 and V2 · Issue #83 · microbit-foundation/micropython-microbit-v2 · GitHub
[go: up one dir, main page]

Skip to content

Pin drive strength is not the same V1 and V2 #83

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

Open
DaveAtKitronik opened this issue Jul 26, 2021 · 4 comments
Open

Pin drive strength is not the same V1 and V2 #83

DaveAtKitronik opened this issue Jul 26, 2021 · 4 comments

Comments

@DaveAtKitronik
Copy link

Reported by a customer - the ZIP64 does not function correctly with microPython on a V2 microbit.
This is the same as a resolved issue in makecode. (microsoft/pxt-microbit#3825).

We added:
#if MICROBIT_CODAL
uBit.io.P0.setHighDrive(true);
#endif
in a c++ shim to fix it there. Not sure where a fix would be applied in microPython - to the neopixel code (baked in), or to just expose the ability to change the pin drive strength from the python code

DaveAtKitronik added a commit to KitronikLtd/micropython-microbit-kitronik-game-zip-64 that referenced this issue Aug 10, 2021
As a workaround for microbit-foundation/micropython-microbit-v2#83 it was suggested by the micropython team to poke the pin configuration register directly (under the nose of CODAL). Whilst this works Im not convinced its a 'good idea' as a change to the underlying system could render this 'fix' broken. 
It has been tested on V1 and V2 and doesn't appear to have any bad side effects.
@dpgeorge
Copy link
Collaborator

I suggest to change the pin drive strength by writing directly to nRF GPIO registers, using machine.mem32.

@dpgeorge
Copy link
Collaborator

The equivalent C code to set high drive is:

    uint32_t s = PORT->PIN_CNF[PIN] & 0xfffff8ff;
    s |= 3 << 8;
    PORT->PIN_CNF[PIN] = s;

@dpgeorge
Copy link
Collaborator

Here's a function that should be able to set the high drive on a pin (I've not tested it though):

def set_high_drive(port_id, pin_id):
    addr = 0x5000_0000 + port_id * 0x300 + 0x700 + pin_id * 4
    machine.mem32[addr] = (machine.mem32[addr] & 0xffff_f8ff) | 3 << 8

For P0.00 to P0.31 use port_id=0, for P1.00 to P1.15 use port_id=1.

@kevinjwalters
Copy link

I may have duped this with #216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0