This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52832 cannot control a PWM(servo motor) via Bluetooth

I am using the Hackable kit which has nrf52832 to control a servo motor and read accelerometer(AXL335) readings through a iOS app. I am a novice when comes to embedded. I got the ios app ready to send an integer value to the kit. Right now i am using the ble_blinky example from SDK 15 to turn on/off some external LED's and a piezo buzzer. But when i try to run the PWM_Library integrated(basically copy pasted with the pin numbers changed) in the same project the servo motor doesn't run and the program crashes at run time. Can anyone help me to accomplish my goal?

The code i use for BLE is as below.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
APP_PWM_INSTANCE(PWM1,1); // Create the instance "PWM1" using TIMER1.(For Servo Motor)
static volatile bool ready_flag; // A flag indicating PWM status.(For Servo Motor)
void pwm_ready_callback(uint32_t pwm_id) // PWM callback function. (For Servo Motor)
{
ready_flag = true;
}
void servo_config()
{
ret_code_t err_code;
app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(5000L, 2, 3);
/* Switch the polarity of the second channel. */
pwm1_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH;
/* Initialize and enable PWM. */
err_code = app_pwm_init(&PWM1, &pwm1_cfg, pwm_ready_callback);
APP_ERROR_CHECK(err_code);
app_pwm_enable(&PWM1);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
it is same as the ble Blinky with this function added. Also there were some sdk_config changes that were made to compile this code like Enabling NRFX_TIMER = 1.

I am using SEGGER to program and compile the code, and push it to the device using ARM GCC GDB.