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

using custom UART config [needed to program the Artemis Global Tracker] #349

Closed
jerabaul29 opened this issue Feb 12, 2021 · 13 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jerabaul29
Copy link

I have a hard time getting the Iridium on the Artemis Global Tracker to work with the core 2.0.5. See sparkfunX/Artemis_Global_Tracker#19 .

After some debugging, seems this comes from the need to set up a custom serial. This code does not produce a serial output on my computer:

// with this line, do not even get the Serial output
// this is a custom serial for talking to the iridium modem, similar to AGT example 14
UART iridiumSerial(1, 25, 24);

void setup(){
  Serial.begin(115200);
  delay(10);
  Serial.println(F("booted"));
}

void loop(){
  
}

Any idea how to fix this?

@jerabaul29
Copy link
Author

Ok, even something like this fails:

void setup(){
  Serial.begin(115200);
  delay(10);
  Serial.println(F("booted"));

  Serial1.begin(57600);
  delay(10);

  Serial.println(F("done with serial1"));
}

void loop(){
  
}

This prints the first message, but the second message never gets printed.

@jerabaul29
Copy link
Author

Even this does not work (second message not printed)

void setup(){
  Serial.begin(115200);
  delay(10);
  Serial.println(F("booted"));
  Serial.end();

  Serial1.begin(57600);
  delay(10);
  Serial1.end();

  Serial.begin(115200);
  delay(10);
  Serial.println(F("done with serial1"));
}

void loop(){
  
}

@jerabaul29
Copy link
Author

I had a look at the core, and I am really confused about how the following things are implemented:

  • the fact that there are several hardware serials (2 on this board)

vs

  • the fact that each hardware serial can be routed to different pins (RX, TX, and flow control).

Could you extend the serial example to show how a specific hardware serial (1 and 2) can be routed to a specific set of (TX, RX) pins?

@ghost ghost assigned Wenn0101 Feb 26, 2021
@ghost ghost added the bug Something isn't working label Feb 26, 2021
@paulvha
Copy link
Contributor

paulvha commented Mar 1, 2021

Sharing the experience from the good time I spend to understand what is happening, but have not found the solution yet. The problem starts as soon as Serial1 (or any next UART()) is beginning. At the end of each begin(), in hardwareSerial.cpp, it will call attach() for &UART::rxISR and only for RxIrq (meaning receive). This callback is set with attach() in Mbed-drivers Serialbase.cpp. After that Serial will NOT provide any output anymore. BUT I do not understand why... yet. The logic in the program flow is complex, but looks OK to me. I have also changed the way hardwareSerial.cpp is working, applying what Arduino Nano 33 BLE does, but still, no change. It somehow looks to me that the attach() call for a second Serial is overwriting the rxISR call back for (the first) Serial or it is overwriting other memory. Letting a second serial perform all init-actions except an attach() call, the first Serial will continue to work (of course you can NOT receive any data on the second serial). Maybe this helps..
regards,
Paul

@ghost ghost added this to the v2.1.0 milestone Mar 2, 2021
@paulvha
Copy link
Contributor

paulvha commented Mar 5, 2021

This was darn hard to debug and took a long time..but in the end an easy way to reproduce/overcome.

If RX1 is "open", nothing connected it will constantly generate input/interrupts, causing an unresponsive system.

Connect a 10K resistor between +3v3 and RX1... the whole problem is gone. Connect a device to RX1.. the problem is gone.

Connect a 10K resistor between GND and RX1 or leave it floating... you are back in trouble. You do not have this issue on RX0 as the USB interface is connected.

Knowing the issue the solution is even easier, the pin_config for the RX1 pin needs to get an internal pull-up.

in mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/PeripheralPinConfigs.c.
Around line 531, change :

const am_hal_gpio_pincfg_t g_AP3_PER_UART1_RX_25 =
{
    .uFuncSel            = AM_HAL_PIN_25_UART1RX
};

to

const am_hal_gpio_pincfg_t g_AP3_PER_UART1_RX_25 =
{
    .ePullup             = AM_HAL_GPIO_PIN_PULLUP_24K,
    .uFuncSel            = AM_HAL_PIN_25_UART1RX
};

It will get a 24K pull up and of course you need to recompile the libmbed-os.a.

Now it all works: I connected an external device after reset and RX1 works as it should.
regards,
Paul

@jerabaul29
Copy link
Author

Many thanks for your hard work, looking forward to the fix :) .

@rserranosmith
Copy link

I'm sorry, I'm super new to this, I was able to change the PeripheralPinConfigs.c file, but I am unsure of where and how to recompile the limbed-os.a library. Any help would be very much appreciated, thank you for this solution!

@paulvha
Copy link
Contributor

paulvha commented Mar 8, 2021

I had the same question some time ago and got instructions #279. If you are new to this.. it will be a challenge to get it going but you can try, else what board are you using maybe I can create one for your board and sent you a link.
regards,
Paul

@rserranosmith
Copy link

Thank you Paul! That would be super helpful! I am using the Artemis Nano Board!

@paulvha
Copy link
Contributor

paulvha commented Mar 8, 2021 via email

@jerabaul29
Copy link
Author

So is that solved / were you able to add the pullups settings to the binaries shipped with the package? :)

@Wenn0101
Copy link
Contributor

Fix included v2.1.0

@bimalpaneru
Copy link

bimalpaneru commented Feb 14, 2024

Following up on this issue, I have been trying to use Pin AUD_BCLK for Tx and AUD_LRCLK for Rx for a RS485 module.

Been having the issue during the receiving. Nothing is being received on the Rx line whereas TX seems perfectly fine. I do not even know what might be causing this, think this is the closest thread to my problem.

I have 10k pullup on the Rx line in saying that with or without pullup nth changes.

I am using a micromod variant of artemis with 19200 SERIAL_8E1.

Would really appreciate any suggestions on potential solution to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants