8 years, 6 months ago.

UART clash with device initialization

Hi everyone, I am struggling with an UART device using it with my nucleo.

I am using the F401RE nucleo with the mikroe RFID click, the click uses the ST CR95HF http://www.st.com/content/st_com/en/products/memories/nfc-rfid-memories-and-transceivers/nfc-rfid-transceivers/cr95hf.html

in the datasheet, the RFID needs to receive a pull down pulse for about 150us on the rx pin (connected to my tx pin on the nucleo PA_9) and then it will be active.

problem is that I declare the RFID as a serial port globally, so I cant set the pin as a digital output outside the main function, giving me a code similar to this:

  1. include "mbed.h" Serial RFID(PA_9, PA_10);tx and rx

int main(void) { DigitalOut RF_tx(PA_9); RF_tx = 0; wait_us(10); RF_tx = 1; wait_us(200); RF_tx = 0; wait_us(1); while(1) { do stuff } }

is there a way that I can use the uart tx pin as a digital pin for a bit and set it as a uart tx pin again after? thanks

1 Answer

8 years, 6 months ago.

Well one way is to declare the serial port a second time after sending the pulse. This will reconfigure the pins back to UART mode. The second time you can declare the port inside a block { Serial RFID(PA_9, PA_10); } so the second "serial" object doesn't persist.

Accepted Answer

it worked! I thought you had to declare serial outside the main loop. simple fix.

one more thing, do you know how to use NVIC_Disable_Irq() in a nucleo f401re? im trying to figure it out, but its not working when I try

NVIC_DisableIRQ(RFID.RxIrq)

I am not sure how to use NVIC_Disable_Irq, I cant find the library that may have the function and im not sure what to place in the brackets. thanks!

posted by ovi rahman 14 Jun 2016

I can't say with any certainty but if you search on "NVIC_Disable_Irq" you'll probably hit the right answer or something close.

More importantly: are you certain you need to disable the interrupt? If you have small critical sections you might consider masking all interrupts, alternatively if you are not using the callback then detach it.

posted by Oliver Broad 14 Jun 2016

well, I am trying to receive something in particular, and I am getting partial gibberish sometimes, exploring options, so I thought maybe disabling interrupts would work. but detaching the interrupt isnt a bad idea. let me try some things. for now I think this is sufficient, I will post a question again if push comes to shove. thanks a lot, appreciate the help

posted by ovi rahman 15 Jun 2016