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

samples: nrfx_prs: Fix sample frequency and baudrate #71157

Merged
merged 3 commits into from
Apr 12, 2024

Conversation

joerchan
Copy link
Contributor

@joerchan joerchan commented Apr 5, 2024

Fix sample frequency and baudrate.
The nrfx drivers are now using raw integere values instead of nrf definitions.

Add handling of SCK initial value based on the SPI mode used.
If mode is using CPOL then SCK needs to be set.

Fixes: #71154

@@ -221,7 +226,7 @@ static bool switch_to_uarte(void)
nrfx_uarte_config_t uarte_config = NRFX_UARTE_DEFAULT_CONFIG(
NRF_UARTE_PSEL_DISCONNECTED,
NRF_UARTE_PSEL_DISCONNECTED);
uarte_config.baudrate = NRF_UARTE_BAUDRATE_1000000;
uarte_config.baudrate = MHZ(1);
Copy link
Member

@anangl anangl Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect. The field here is still of the enumerated type, so this line should stay untouched.

The UARTE initialization fails due to a different reason - the RXSTARTED event appears to be set because its register is at the same location as the SPIM event STARTED. So we'll need something like:

	/* Make sure all SPIM events are cleared. */
	nrfy_spim_int_init(spim.p_reg, 0xFFFFFFFF, 0, false);

in the if (spim_initialized) block right above and a similar clean-up in switch_to_spim().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. thanks.

I tested with your workarounds an it works.

However to me it seems like this should be part of nrfx uninit function.
Clearing the event registers seems like an important step. For example if these functions are used in this scenario, or between images in a bootchain, like mcuboot -> tf-m -> application.

It can be added here as a temporary workaround until a new release of NRFX of course.

@joerchan joerchan requested a review from anangl April 9, 2024 11:54
@joerchan
Copy link
Contributor Author

joerchan commented Apr 9, 2024

@anangl Added workarounds.

I think the proper fix is to make sure that events get cleared in the nrfx_<peripheral>_uninit functions.
That seems important for a lot of cases, especially boot-loader chained boot (including with TF-M).

@anangl
Copy link
Member

anangl commented Apr 9, 2024

@anangl Added workarounds.

Did you forget to push the branch?

I think the proper fix is to make sure that events get cleared in the nrfx__uninit functions. That seems important for a lot of cases, especially boot-loader chained boot (including with TF-M).

I completely agree, this should be ultimately addressed in nrfx.

Joakim Andersson added 2 commits April 10, 2024 14:34
Fix setting of sample frequency.
The nrfx drivers are now using raw integere values instead of nrf
definitions.

Fixes: zephyrproject-rtos#71154

Signed-off-by: Joakim Andersson <joakim.andersson@heimdallpower.com>
Add handling of SCK initial value based on the SPI mode used.
If mode is using CPOL then SCK needs to be set.

Fixes: zephyrproject-rtos#71154

Signed-off-by: Joakim Andersson <joakim.andersson@heimdallpower.com>
@joerchan joerchan force-pushed the prs-frequency-fixes branch from 71b8ccb to 9a68c15 Compare April 10, 2024 12:36
@joerchan
Copy link
Contributor Author

Did you forget to push the branch?

Sorry, pushed now.

Add workaround for uninit functions not clearing events for
spim and uarte.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
@joerchan joerchan force-pushed the prs-frequency-fixes branch from 9a68c15 to 177329a Compare April 11, 2024 08:11
@joerchan joerchan requested a review from anangl April 11, 2024 08:11
@carlescufi carlescufi merged commit eb13383 into zephyrproject-rtos:main Apr 12, 2024
17 checks passed
@joerchan joerchan deleted the prs-frequency-fixes branch April 12, 2024 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

samples: nrfx_prs: Failing after nrfx update
5 participants