[DEV] STM32G4xx support

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 12743
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 693 times
Been thanked: 572 times
Contact:

Re: [DEV] STM32G4xx support

Postby Giovanni » Sun Oct 06, 2019 2:21 pm

Support for DAC3 and DAC4 has been added but it is untested.

Giovanni

JMifune
Posts: 9
Joined: Mon Jun 24, 2019 11:52 am

Re: [DEV] STM32G4xx support

Postby JMifune » Sun Oct 06, 2019 6:00 pm

Thanks, I've ported DAC1 testhal example, but the DAC streaming callback does not fire.

It is still on DACD1 as in original example, the only changes I made was to DAC_TRG bits - 0x7 for Tim6 on G474.
From the reference manual DAC_TRG_MASK is 4 bits long, but the top bit is used only for HRTIM.

User avatar
Giovanni
Site Admin
Posts: 12743
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 693 times
Been thanked: 572 times
Contact:

Re: [DEV] STM32G4xx support

Postby Giovanni » Sun Oct 06, 2019 6:36 pm

There must be some problem in DMA-related changes.

Giovanni

JMifune
Posts: 9
Joined: Mon Jun 24, 2019 11:52 am

Re: [DEV] STM32G4xx support

Postby JMifune » Sun Oct 06, 2019 9:42 pm

Looks like it. DAC itself works, output is stuck on initial value.

I've tried to route DAC3 and DAC4 outputs through opamps configured as followers.
Always get ~0.6V on outputs, no matter the DACs initial values.

User avatar
Giovanni
Site Admin
Posts: 12743
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 693 times
Been thanked: 572 times
Contact:

Re: [DEV] STM32G4xx support

Postby Giovanni » Mon Oct 07, 2019 8:49 am

There were 2 problems:

1) DMAMUX was not activated on G4 and this prevented triggering.

2) DACv1 was accessing DAC registers using half word accesses, this is forbidden, accesses must be performed using full words. This used to work on previous devices (violating RM specification) and stopped working on G4.

Now I reworked the driver to use 32 bits accesses everywhere and it seems to work but I cannot test it fully, I would be grateful if everybody could give it a try now. If it is OK then I will also backport it to 18.2 and 19.1. I also cleaned some parts, the driver was a bit old.

Note, there is a G4 builder in the /testhal/STM32/multi/DAC demo now.

Giovanni

JMifune
Posts: 9
Joined: Mon Jun 24, 2019 11:52 am

Re: [DEV] STM32G4xx support

Postby JMifune » Mon Oct 07, 2019 11:37 am

Yes, I have tested it DMA and DAC1 output is working now.

Still can not figure out why I can not get signal out of DAC3/4.
DMA is working on DACD5-8 and all opamps enabled as followers and working properly when VP_SELs are set to connect to external pins.
But when I set OPAMPx_CSR VP_SEL to 11 to connect to DAC output, then opamp outputs are at contstant ~0.6V.

JMifune
Posts: 9
Joined: Mon Jun 24, 2019 11:52 am

Re: [DEV] STM32G4xx support

Postby JMifune » Mon Oct 07, 2019 7:33 pm

Tried the same opamp6 config + DAC3 CH1 in CubeMX.
It works.

JMifune
Posts: 9
Joined: Mon Jun 24, 2019 11:52 am

Re: [DEV] STM32G4xx support

Postby JMifune » Tue Oct 08, 2019 5:02 pm

I've figured it out.
Before enabling DAC3/4, DAC_MCR register MODEx bits must be set to 011 (DAC channelx is connected to on chip peripherals with Buffer disabled).
Default MODE bits are 000 (external pin with Buffer enabled), witch is not an option for DAC3/4.
Also HFSEL bits must be managed according to different AHB speeds.

julester23
Posts: 6
Joined: Sat Jan 04, 2020 5:25 pm
Has thanked: 1 time

Re: [DEV] STM32G4xx support

Postby julester23 » Sun Jan 05, 2020 6:44 am

I have been working on getting the FDCAN peripheral to work on the STM32G434, and have some working internal loopback demos working. I tried submitting to ChibiOS-Contrib, however the pull request I created depends on many of the additions in Chibios-RT master (not in stable_19.1.X). Would it be possible to backport the STM32G support into stable 19? or is 20 coming out soon? or would you be interested in getting some of this work into the mainline ChibiOS-RT? Please let me know if there's anything I can do to help get CAN support in the STM32G series.

I admit it is not complete, but I tried to follow the naming and style as much as possible.

One way or the other (merging both would be redundant):
ChibiOS-Contrib Branch which depends on master branch of ChibiOS-RT and so it is not merge-able.
ChibiOS Branch with a "CANv2" driver.

Thanks for your help.

User avatar
Giovanni
Site Admin
Posts: 12743
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 693 times
Been thanked: 572 times
Contact:

Re: [DEV] STM32G4xx support

Postby Giovanni » Mon Jan 06, 2020 12:33 pm

julester23 wrote:I have been working on getting the FDCAN peripheral to work on the STM32G434, and have some working internal loopback demos working. I tried submitting to ChibiOS-Contrib, however the pull request I created depends on many of the additions in Chibios-RT master (not in stable_19.1.X). Would it be possible to backport the STM32G support into stable 19? or is 20 coming out soon? or would you be interested in getting some of this work into the mainline ChibiOS-RT? Please let me know if there's anything I can do to help get CAN support in the STM32G series.


Hi,

Good work, I examined it briefly and there are some things I observed:
- It should be named FDCANv1 as the current rule is that LLDs take the name of the peripheral (CANv1 is historically wrong, it should be BXCANv1).
- The number of RX and TX mailboxes is set to 1, I believe there are more.
- IO macros are not very efficient, it forces the compile to write and/or read the register each time because the volatile attribute, the preferred way is to prepare a variable with all values the do a single write (unless things need to be written is sequence separately which is sometime required). In general I prefer to read/modify/write explicitly.

Overall it needs some more work.

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 4 guests