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

PWM Modul crash after start advertising.

Hi all,

i have a problem with my pwm modul, if i use my setPWM Function before i start advertising it works fine. But if if i use PWM after starting advertising it doesn't work anymore. I use Timer 2 ang gpiote chanel 0 and 1. What could be a reason for crashing my pwm modul?

Best regards Nils :)

  • Maybe a reason for crashing could also bee, that i use 2 giote members for handl my two buttons.

  • Hi, i just checked my code again and found, It its maybe not beacouse of the softdevice, maybe its becaouse of me gpiote handle. If i call the Gpiote interrupthandler the pressing the button no pwm and no delay (delay with the apptimer) works.here is my code

    
    void gpiote_init									(void)											// Initialisierung des GPIOTE Moduls
    {
    		uint32_t err_code;
    	
        uint32_t pin_mask1 = (1 << BUTTON_EIN);
    		uint32_t pin_mask2 = (1 << BUTTON_AUS);
    	
    	  APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
        NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_HIGH);
    
        // We want to be notified both on rising and falling edge. 
        err_code = app_gpiote_user_register(&m_gpiote_user_id_ein, pin_mask1, pin_mask1, gpiote_event_handler_ein);
        APP_ERROR_CHECK(err_code);
        
    		err_code = app_gpiote_user_register(&m_gpiote_user_id_aus, pin_mask2, pin_mask2, gpiote_event_handler_aus);
        APP_ERROR_CHECK(err_code);
    	
        err_code = app_gpiote_user_enable(m_gpiote_user_id_ein);
        APP_ERROR_CHECK(err_code);
    	
    	  err_code = app_gpiote_user_enable(m_gpiote_user_id_aus);
        APP_ERROR_CHECK(err_code);	
    	
    		uartStr("\n** GPIO Task Events erstellt                **");
    
    		// NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
        // NVIC_EnableIRQ(GPIOTE_IRQn);
    }
    
    // The button eventhandler for shortpress 
    void button_ein_short_pressed			(void * p_context)					// Timeouthandler für createTimerforGPIO
    { 	
    	if (device_status == true && bt_ein_enable == true) 		// Ist das Gerät an?
    	{	
    		app_timer_stop 	(m_timer_id_ein_long_push);			// Timer wird angehalten 
    	
    		if (bt_count != bom_config_stat.TherapieIntensiSchritte)
    		{
    			bt_count++;
    			uartStr("\n** Taster |Ein +| wurde gedrueckt           **");
    		}
    		else
    		{
    			uartStr("\n** Maximaler Tasterwert erreicht            **");
    		}
    	}
    	else													// Ansonsten muss 2 Skeunden lang gedrückt werden
    	{
    		uint32_t err_code;
    			
    		err_code = app_timer_start(m_timer_id_ein_long_push, BUTTON_LONG_PRESSED, NULL);
    		APP_ERROR_CHECK(err_code);
    	}
    }
    
    
  • Do i have to look for something special to use gpiote, becaouse i think that the gpiote makes some errors in my Code.

  • Hi does no one have an idea what a reason for a crash could be? My Problem is, if i press my off button (doesn't matter if i use app_button or using gpiote) a timer is started. If the timer is finished it calls the button timeout handler which is a "System_off Function" And if i call In the Function a function which turn on the PWM (like set_pwm (128)) or if i use my wait function (using app_timer to wait some milliseconds) th processor crashes and doesn#t reset the System like i need.

    What reason could it have the this happens?

    best regards Nils Minor

Related