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

rv_timer_approximate_tick_params bug #420

Open
Ho3eintaji opened this issue Oct 25, 2023 · 5 comments
Open

rv_timer_approximate_tick_params bug #420

Ho3eintaji opened this issue Oct 25, 2023 · 5 comments
Assignees

Comments

@Ho3eintaji
Copy link
Contributor

Ho3eintaji commented Oct 25, 2023

@davideschiavone, I ran into a bug while using the timer in Heepocrates which probably the same story for xheep. The function "rv_timer_approximate_tick_params" which is used for setting prescale and step params based on CPU freq and desired timer freq is not working well and most of the times it returns 0 for these params

@davideschiavone
Copy link
Collaborator

I guess it is due to the time requested and frequency at which you are running - I am not familiar with the HAL of the timer, it is from OpenTitan - maybe you want to have a look there?

@Ho3eintaji
Copy link
Contributor Author

Ok, I checked, it comes from Euclidean GCD used in the function. Actually, it happens when CLK_FREQ and desired TIMER_FREQ have small gcd (for example 1 !), it put large value for prescale (CLK_FREQ/ gcd) which is larger than what timer support so it returns 0 as not supported.

So should be either we change this function to be more approximate or be careful while putting clk and desired timer frequency.

@davideschiavone
Copy link
Collaborator

changing the function should be better in my opion

@JoseCalero
Copy link
Collaborator

@Ho3eintaji is this fixed then?

@Ho3eintaji
Copy link
Contributor Author

No. atm, in my app, I check whether this happens or not:
rv_timer_approximate_tick_params(SYS_FREQ, TIMER_FREQ, &tick_params);
if (tick_params.prescale==0){
printf("Timer approximate function was not able to set a correct value prescale");
}

Later, I will change the function inside to prevent it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants