Hi, i am using Nrf52 DK board and i am working on TWI to get accelerometer(MMA7660) values using TWI driver. so that i am getting accelerometer values and Tap information and i am able to print this info on UART.
in this process i have initialized and enabled PWM(integrated PWM Library example) by taping Button1. if i start the PWM i am able to print and observe duty cycle values on UART but Accelerometer is stoping. how i can TWI and PWM parallelly.
my aim is i need to run both TWI and PWM same time. if i TAP on accelerometer i need to print exact duty cycle value on UART, but at a time i unable to run Both. Thank you.
This is the Code:
int main(void)
{
uint32_t err_code;
bool erase_bonds;
// Initialize.
buttons_leds_handler_init(&erase_bonds);
uart_handler_init();
ble_stack_handler_init();
ble_advertising_start(BLE_ADV_EVT_FAST);
printf("Starting low power working on\r\n");
MMA7660_init();
//i2cHandler_init();
//
for(;;){
low_power_manager();
///Accelerometer....
uint8_t reg = 0;
nrf_delay_ms(10);
/* Start transaction with a slave with the specified address. */
err_code = nrf_drv_twi_tx(&m_twi_mma_7660, MMA7660_ADDR, ®, sizeof(reg), true);
APP_ERROR_CHECK(err_code);
if(err_code != NRF_SUCCESS){
printf("ACCELEROMETER ERROR\r\n");
}
if(is_ButtonTapeOccured()){ /// true if i TAP button on DK board..
// app_pwm_channel_duty_set(&pwm_library, 0, 100);
start_PWM(); ///started PWM at pin NUM ARDUINO_13_PIN i.e P0.25
}
}
}