Generated Board.h File from CubeMX

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Generated Board.h File from CubeMX

Postby JSStabl » Wed Oct 21, 2020 10:39 am

Hi,

I used the python script found in https://github.com/ChibiOS/ChibiOS-Cont ... .3.x/tools to generate a board file. I used all the other settings from the STM327F767 Board file.

Previously I had set my pins over the C code i.e. with:

Code: Select all

palSetPadMode(GPIOD, 1, PAL_MODE_ALTERNATE(8) | PAL_STM32_OSPEED_HIGHEST); // RX 4


For the UART. To make life easier I want to set those pins over the board.h, which I understand it's for right?
However when I set my pins for the UART4 with this code:

Code: Select all

/* PORT D */
#define VAL_GPIOD_MODER ( \
    PIN_MODE_ALTERNATE(1) | \
    PIN_MODE_ALTERNATE(2) | \
    PIN_MODE_ANALOG(2) | \
    PIN_MODE_ANALOG(3) | \
    PIN_MODE_ANALOG(4) | \
    PIN_MODE_ALTERNATE(5) | \
    PIN_MODE_ALTERNATE(6) | \
    PIN_MODE_ALTERNATE(7) | \
    PIN_MODE_ALTERNATE(8) | \
    PIN_MODE_ALTERNATE(9) | \
    PIN_MODE_OUTPUT(10) | \
    PIN_MODE_OUTPUT(11) | \
    PIN_MODE_OUTPUT(12) | \
    PIN_MODE_OUTPUT(13) | \
    PIN_MODE_ANALOG(14) | \
    PIN_MODE_ANALOG(15) | \
    0)

#define VAL_GPIOD_OTYPER ( \
    PIN_OTYPE_PUSHPULL(0) | \
    PIN_OTYPE_PUSHPULL(1) | \
    PIN_OTYPE_PUSHPULL(2) | \
    PIN_OTYPE_PUSHPULL(3) | \
    PIN_OTYPE_PUSHPULL(4) | \
    PIN_OTYPE_PUSHPULL(5) | \
    PIN_OTYPE_PUSHPULL(6) | \
    PIN_OTYPE_PUSHPULL(7) | \
    PIN_OTYPE_PUSHPULL(8) | \
    PIN_OTYPE_PUSHPULL(9) | \
    PIN_OTYPE_PUSHPULL(10) | \
    PIN_OTYPE_PUSHPULL(11) | \
    PIN_OTYPE_PUSHPULL(12) | \
    PIN_OTYPE_PUSHPULL(13) | \
    PIN_OTYPE_PUSHPULL(14) | \
    PIN_OTYPE_PUSHPULL(15) | \
    0)

#define VAL_GPIOD_OSPEEDR ( \
    PIN_OSPEED_MEDIUM(0) | \
    PIN_OSPEED_MEDIUM(1) | \
    PIN_OSPEED_VERYLOW(2) | \
    PIN_OSPEED_VERYLOW(3) | \
    PIN_OSPEED_VERYLOW(4) | \
    PIN_OSPEED_MEDIUM(5) | \
    PIN_OSPEED_MEDIUM(6) | \
    PIN_OSPEED_MEDIUM(7) | \
    PIN_OSPEED_MEDIUM(8) | \
    PIN_OSPEED_MEDIUM(9) | \
    PIN_OSPEED_VERYLOW(10) | \
    PIN_OSPEED_VERYLOW(11) | \
    PIN_OSPEED_VERYLOW(12) | \
    PIN_OSPEED_VERYLOW(13) | \
    PIN_OSPEED_VERYLOW(14) | \
    PIN_OSPEED_VERYLOW(15) | \
    0)

#define VAL_GPIOD_PUPDR ( \
    PIN_PUPDR_FLOATING(0) | \
    PIN_PUPDR_FLOATING(1) | \
    PIN_PUPDR_FLOATING(2) | \
    PIN_PUPDR_FLOATING(3) | \
    PIN_PUPDR_FLOATING(4) | \
    PIN_PUPDR_FLOATING(5) | \
    PIN_PUPDR_FLOATING(6) | \
    PIN_PUPDR_FLOATING(7) | \
    PIN_PUPDR_FLOATING(8) | \
    PIN_PUPDR_FLOATING(9) | \
    PIN_PUPDR_FLOATING(10) | \
    PIN_PUPDR_FLOATING(11) | \
    PIN_PUPDR_FLOATING(12) | \
    PIN_PUPDR_FLOATING(13) | \
    PIN_PUPDR_FLOATING(14) | \
    PIN_PUPDR_FLOATING(15) | \
    0)

#define VAL_GPIOD_ODR ( \
    PIN_ODR_LOW(0) | \
    PIN_ODR_LOW(1) | \
    PIN_ODR_LOW(2) | \
    PIN_ODR_LOW(3) | \
    PIN_ODR_LOW(4) | \
    PIN_ODR_LOW(5) | \
    PIN_ODR_LOW(6) | \
    PIN_ODR_LOW(7) | \
    PIN_ODR_LOW(8) | \
    PIN_ODR_LOW(9) | \
    PIN_ODR_LOW(10) | \
    PIN_ODR_LOW(11) | \
    PIN_ODR_LOW(12) | \
    PIN_ODR_LOW(13) | \
    PIN_ODR_LOW(14) | \
    PIN_ODR_LOW(15) | \
    0)

#define VAL_GPIOD_AFRL ( \
    PIN_AFIO_AF(0, 8) | \
    PIN_AFIO_AF(1, 8) | \
    PIN_AFIO_AF(2, 0) | \
    PIN_AFIO_AF(3, 0) | \
    PIN_AFIO_AF(4, 0) | \
    PIN_AFIO_AF(5, 7) | \
    PIN_AFIO_AF(6, 7) | \
    PIN_AFIO_AF(7, 5) | \
    0)

#define VAL_GPIOD_AFRH ( \
    PIN_AFIO_AF(8, 7) | \
    PIN_AFIO_AF(9, 7) | \
    PIN_AFIO_AF(10, 0) | \
    PIN_AFIO_AF(11, 0) | \
    PIN_AFIO_AF(12, 0) | \
    PIN_AFIO_AF(13, 0) | \
    PIN_AFIO_AF(14, 0) | \
    PIN_AFIO_AF(15, 0) | \
    0)


The uart does not work (when running palSetPadMode does). Is the script outdated an the board.h code doesn't work like this?

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

Re: Generated Board.h File from CubeMX

Postby Giovanni » Wed Oct 21, 2020 11:35 am

Board.h is meant for that, you have some error in it or you are assigning the UART lines to multiple pins.

Giovanni

JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Re: Generated Board.h File from CubeMX

Postby JSStabl » Wed Oct 21, 2020 11:39 am

Hi Giovianni,

thanks for the clarification, whats the fastest way to debug that? Do you know if the cubemx script is still working?

Thanks!

JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Re: Generated Board.h File from CubeMX

Postby JSStabl » Wed Oct 21, 2020 3:55 pm

Removed all the palSetLineMode Commands and now it seems to work :)


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 4 guests