-
Notifications
You must be signed in to change notification settings - Fork 36
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
No serial RX on UART1 when using non-default pins #401
Comments
More observations on this: This works:
This does not work:
If I edit variant.cpp for the ARTEMIS_ATP and change this line:
to:
then this works:
So, pin 12 and 13 do work OK. It's not a configuration or hardware issue as such. But something is stopping If I edit variant.cpp for the ARTEMIS_ATP and comment line 8. And also edit variant.h and comment line 26:
Then my original script ( OK. So is there a way to persuade the core to let us 'reallocate' the pins for UART1 if Serial1 already exists? I shall dig some more... |
Hey Paul! interesting stuff so far! I am trying out your sketches now. I'll let you know what I find! |
There's no rush on this... (Please don't ruin your evening by diving into this!) |
I think you have really narrowed down the problem. The issue seems to be more about the fact that declaring a "new" serial should really be more changing the configuration of the already initialized hardware serial to new pins. I wonder if this logic should happen at a higher level. |
More thoughts on this: I can see how having two pins - 13 and 25 - configured for UART1 RX via the pin .uFuncSel would cause problems. But I don't think that is the core issue here. If it was then So, following the trail of breadcrumbs: Going back to At the moment, this still has me stumped. I have a J-Link debug cable on order; I hope the debug interface may provide more clues... A quick fix would be to define a new variant for the OLA, which does not define Serial1. But that wouldn't help anyone trying to use non-default pins on e.g. the ATP... |
Is there any way that we could be calling |
ok. Here is a spooky finding.
This sketch works... |
Also, a workaround. I have fixed the Artemis Module target (on the dev branch not released yet), this may be a better suited base target for this kind of project. |
Indeed - thank you! I did spot the issues with the "Module" but didn't want to spoil your day with them... |
I believe i fixed nates issue with this commit, but this could be related/similar. |
So, it looks like the root cause of this might indeed be due to the order in which things happen - agreeing with your spooky finding. If I upload this sketch:
and I have ATP selected as the board, then I see First call: note that R1 contains "0xC" = Pin 12 and that R2 contains "0xD" = Pin 13. I.e. this is the init for mySerial: Second call: this must be Serial1 as R1 is 24 and R2 is 25: Third call: this must be Serial (USB) as R1 is 48 and R2 is 49: So, it looks like mySerial is being initialized correctly, first, but it is then being hijacked by Serial1! I don't yet have a theory on why I still see data being transmitted on Pin 12 though... Unless Pin 12 is left as a duplicate TX pin? Time to test a jumper from pin 12 to pin 25... Watch this space! |
Hah!
|
So.... Serial and Serial1 are being |
I am going to close this one out. The artemis module is now available to those creating new boards. |
Background:
I'm updating OpenLog Artemis to use v2.1.0 of the core. All is going well(ish) but I'm not able to receive any serial data on UART1. OpenLog Artemis uses pin 12 for Tx and pin 13 for Rx. Serial Tx on pin 12 works fine, I'm just not able to receive anything on pin 13.
Steps to replicate:
RedBoard Artemis ATP
v2.1.0 of the core
Use a jumper wire to link pin 12 to pin 13
Run this sketch:
Open the serial monitor, and you should see this (captured using Serial1 on pins 24 and 25):
Instead, we get this:
Putting a logic analyzer on the jumper wire, I can see pin 12 transmitting:
So the issue is somewhere in the receive functionality.
I started digging into the core UART code, but I haven't found a smoking gun so far. It looks like pin 13 should be being configured correctly:
https://github.com/sparkfun/mbed-os-ambiq-apollo3/blob/be07f057170a4e9ed4a286abb2170b9df3d52de3/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPins.c#L104
https://github.com/sparkfun/mbed-os-ambiq-apollo3/blob/be07f057170a4e9ed4a286abb2170b9df3d52de3/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPinConfigs.c#L500-L509
https://github.com/sparkfun/mbed-os-ambiq-apollo3/blob/be07f057170a4e9ed4a286abb2170b9df3d52de3/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/sdk/mcu/apollo3/hal/am_hal_pin.h#L165
I'm out of ideas... Any suggestions on where to dig next?
Cheers!
Paul
The text was updated successfully, but these errors were encountered: