[NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
ryo
Posts: 2
Joined: Thu May 03, 2018 6:53 am

[NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Post by ryo » Thu May 03, 2018 8:04 am

Hello.
I am a Japanese living in Japan.
Posted while being helped by Google translation.

I purchased NUCLEO-L476RG.

I downloaded the dfu file from the following URL.
http://micropython.org/resources/firmwa ... v1.9.3.dfu

After converting to hex file with DfuFileMgr.exe, we have written hex file to NUCLEO-L476RG with STM32 ST-LINK Utility.exe.
I connected the NUCLEO-L476RG to a PC via USB, and confirmed that the following code works correctly.
-----
>>> MicroPython v1.9.3 on 2017-11-01; NUCLEO-L476RG with STM32L476RG
Type "help()" for more information.
>>> print('hello')
hello
>>>
-----

I tried trying ADC and DAC as the next step, but I faced several problems.

1.I do not know the association between the name of the pin and the pin on the actual board. Is there a list or image somewhere?
2.An error occurred when trying to use the DAC. In this case, do I need to activate the DAC and recompile the dfu file?
In that case, which part should be changed?

-----
>>> import DAC
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'DAC'
>>>
>>> from pyb import DAC
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name DAC
>>>
----


I looked at various Web sites, but I could not find useful information.
(Although I am not good at English, it is one of the causes)

If the place to post is incorrect, please tell me the right place.
If I violate the forum rules, please tell me the bad things.

Thank you.

torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: [NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Post by torwag » Thu May 03, 2018 2:10 pm

Hi,

you might go to github to read in the source code files what is available and what is the pin assignment.

E.g.

https://github.com/micropython/micropyt ... LEO_L476RG

Each board has a pin.csv file which depicts the relation between the physical pins and the naming.

Within the source code files (mpconfigboard.h) you can also find, what kind of modules are ported to the platform etc.
E.g. In your case, I can't see that

MICROPY_HW_ENABLE_DAC is set
which most likely explain why you can't call the DAC functions.

Hope that is a good start.

ryo
Posts: 2
Joined: Thu May 03, 2018 6:53 am

Re: [NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Post by ryo » Sat May 05, 2018 12:43 pm

Hello.

>you might go to github to read in the source code files what is available and what is the pin assignment.

Thank you.
I was able to understand it.

>Within the source code files (mpconfigboard.h) you can also find, what kind of modules are ported to the platform etc.
>E.g. In your case, I can't see that

I see.
Certainly I could not find it, either.
Sorry, I will look for another way.

Thank you for answering.
It was very helpful.

alecwhardy
Posts: 1
Joined: Fri Jul 20, 2018 7:53 pm

Re: [NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Post by alecwhardy » Fri Jul 20, 2018 7:58 pm

You might be able to solve pin and DAC errors by re-flashing the most recent version of MicroPython. Rather than converting the DFU file to a hex file, you can directly build the hex file from the Github source code.

The whole procedure to build the hex file from the source code is here: http://hardytek.com/flashing-micropytho ... 32-nucleo/

yijunliu
Posts: 3
Joined: Fri Dec 01, 2017 3:12 am

Re: [NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Post by yijunliu » Thu Jul 26, 2018 6:21 am

Hi all,
I’ve successfully followed this link: http://hardytek.com/flashing-micropytho ... 32-nucleo/
to build the hex file, flash into the board and test the ADC.
Here are two problems I encountered:
1. I found that the I2C doesn’t work at all. Has anyone tried yet?
I use the I2C1. As mpconfigboard.h shows, PB6 and PB7 are SCL and SDA respectively.
I deploy two board that communicate with each other through I2C; one as master, the other as slave.
I’ve tried the same code on PYB, which works well.
With the aid of the Logic Analyzer, I found that after executing the following lines of code:

from pyb import I2C
i2c=I2C(1, I2C.MASTER, baudrate=100000)

PB6 and PB7 are not pulled high.

2. I can’t see a PYB Flash, that is I can not see a main.py/boot.py.
How to flash the code into the board once I complete developing?

Any thoughts are welcomed. Thanks.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: [NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Post by pythoncoder » Sun Jul 29, 2018 6:32 am

I2C requires pullups on the scl and sda lines. The Pyboard has these built-in. If your board doesn't have them you'll need to supply them - something around 4.7KΩ, to 3.3V.
Peter Hinch
Index to my micropython libraries.

yijunliu
Posts: 3
Joined: Fri Dec 01, 2017 3:12 am

Re: [NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Post by yijunliu » Tue Jul 31, 2018 8:42 am

Thanks, Peter. The I2C interface works now :)

About my second problem, I use a usb connector as this link suggests
viewtopic.php?t=2343
I can see the PYB flash now and put my whole code in boot.py (somehow not main.py) to successfully boot.
Hardy has provided another way to access the PYB flash with the ST-Link programmer’s USB port, which looks like a better solution.
http://hardytek.com/writing-files-to-nucleo-pyb-flash/
Thanks, Hardy.

Since I'll eventually cut the ST-link part from the main board to minimize the overall power consumption, which is one of the goal of the prototype system, I think a usb connector is still a necessity for me to re-flash when needed.

yijunliu
Posts: 3
Joined: Fri Dec 01, 2017 3:12 am

Re: [NUCLEO-L476RG/STM32L476RGT6]Pin Association and DAC Error

Post by yijunliu » Wed Aug 01, 2018 9:16 am

Hello forum,
I'm back again. We've cut the ST-LINK from the main board and injected power through CN6 (3.3V and GND).
Now the current is about 10mA/1.8V with default system frequency 80MHz.
This is not satisfying and we'd like to lower the power consumption with lower system freq.
However, it seems that the system frequency of this board can not be modified yet.
For PYB, the system frequency can be set with pyb.freq(target_freq) at the very first line of boot.py.
But it fails on this board. I tried this in REPL:

>>> pyb.freq(24000000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NotImplementedError: machine.freq set not supported yet
>>>

Any comments are welcomed. Thanks!

Post Reply