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

NRF52 Can not initialize Pwm #7743

Closed
MateuszMaz opened this issue Aug 9, 2018 · 9 comments
Closed

NRF52 Can not initialize Pwm #7743

MateuszMaz opened this issue Aug 9, 2018 · 9 comments

Comments

@MateuszMaz
Copy link
Contributor

Description

After following commit: 2ba88ba, that was made soon after mbed-os-5.9.0 it is no longer possible to create an object of PwmOut class for device NRF52832. The error exist in every version of mbed-os since 5.9.1 to current 1ab05c2.

Mbed error string:

++ MbedOS Error Info ++
Error Status: 0x80FF0100 Code: 256 Module: 255
Error Message: Fatal Run-time error
Location: 0x3683D
Error Value: 0x0
Current Thread: Id: 0x2000534C Entry: 0x32D45 StackSize: 0x1000 StackMem: 0x20005398 SP: 0x200062C8
-- MbedOS Error Info --
nrf failure at .\mbed-os\targets\TARGET_NORDIC\TARGET_NRF5x\TARGET_SDK_14_2\drivers_nrf\pwm\nrf_drv_pwm.c:192

Target:
NRF52832
Mbed-OS SHA
current master: 1ab05c2
Toolchain
GCC_ARM 7 2018-q2-update

Steps to reproduce

  1. Create a new mbed program
  2. checkout mbed-os to 1ab05c2
  3. Create main.cpp with following declaration PwmOut led(LED1);
  4. Run and read error from terminal

Issue request type

[ ] Question
[ ] Enhancement
[x] Bug

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 9, 2018

Why that error is happening ? Based on the referenced commit, I would assume that previously it was happening , it was just silenced ?
[Mirrored to Jira]

@MateuszMaz
Copy link
Contributor Author

MateuszMaz commented Aug 9, 2018

During pwm initialization we check if no other object of current pwm is already initialized

/* Make sure PWM instance is not running before making changes. */
nrf_drv_pwm_uninit(&nordic_nrf5_pwm_instance[obj->instance]);

The problem is since nref asserts were redirected to mbed error (2ba88ba),
line 192 in nrf_drv_pwm.c of function nrf_drv_pwm_uninit() visible below:

ASSERT(p_cb->state != NRF_DRV_STATE_UNINITIALIZED);

now returns an error because:

void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
{
ASSERT_TRUE(false, (void) 0);
}

was changed to:

void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
{
error("nrf failure at %s:%d", p_file_name, line_num);
}

It was silenced. When we initialize object first time, then this thing: nrf_drv_pwm_uninit(&nordic_nrf5_pwm_instance[obj->instance]);
in pwmout_api.c during initialization was always returning failed asert, but now it is an error

I think the problem is pwmout_api, because this function nrf_drv_pwm_uninit(&nordic_nrf5_pwm_instance[obj->instance]);
was intented to return an error when we try to uninitialize the module that was not initialized,
and it is confusing, when we are using it to check if object is not initialized in static void nordic_pwm_init(pwmout_t *obj) in pwmout_api.c of NRF52.
[Mirrored to Jira]

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 10, 2018

@MateuszMaz Can you fix it ?
[Mirrored to Jira]

@MateuszMaz
Copy link
Contributor Author

MateuszMaz commented Aug 13, 2018

here is pr #7779
[Mirrored to Jira]

@AGlass0fMilk
Copy link
Member

AGlass0fMilk commented Aug 24, 2018

What is the status of this? I have been unable to use PwmOut on nRF5X platforms up til now (causes a "fatal error" immediately). This is quite a severe issue.
[Mirrored to Jira]

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 24, 2018

@AGlass0fMilk Does #7779 fixes the issues you are having?
[Mirrored to Jira]

@MateuszMaz
Copy link
Contributor Author

MateuszMaz commented Aug 24, 2018

#7779 is intended to fix it for nrf52832 and nrf52840
[Mirrored to Jira]

adbridge pushed a commit that referenced this issue Sep 7, 2018
Deleted lines that caused the problem. Note that, in nrf_drv_pwm_init there are lines that check if pwm instance is already running, so we don't even need to check it in nordic_pwm_init.
nrf_drv_uninit should be used in nordic_pwm_restart.
@bmcdonnell-ionx
Copy link
Contributor

bmcdonnell-ionx commented Sep 14, 2018

Mbed OS 5.9.7 release notes links to this issue as "fixed". Consider closing.
[Mirrored to Jira]

@adbridge
Copy link
Contributor

adbridge commented Oct 4, 2018

Internal Jira reference: https://jira.arm.com/browse/IOTDEV-1598

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

No branches or pull requests

7 participants