[riot-notifications] [RIOT-OS/RIOT] Getting Stack Pointer Corrupted. Reset of top of stack (#16484)

Jacco Veldscholten notifications at github.com
Wed May 19 23:33:09 CEST 2021

#### Description
I'm sending data with LoRa after that im trying to create a PWM signal on a buzzer pin to generate a tone. After the LoRa Message got sended by OTAA there is a error in the Terminal that the stack pointer got corrupt. My question is, how could this happend and what is the best method to debug a stack issue? If i remove the PWM buzzer function it will not create a stack corruption. PWM Should be simple?

**Thread code:**
static void *mainThread(void *arg)

    while (1) {
		printf("Mean Thread Called \n");
		switch (State){
			case Alarm:
				printf("Im in alarm state \n");
				// If LoRaSendAlarm or TurnBuzzerOn got commented it won't crash.
				TurnBuzzerOn();  // Causes error (Stack error)
	return 0;
_Definition of PWM Buzzer:_  `#define PWM_BUZZER PWM_DEV(0)`

**Function TurnBuzzerOn**
void TurnBuzzerOn(void)


**Init PWM**
void Init_PWM(void)
        pwm_init(PWM_BUZZER, PWM_CENTER, freq, (u_int32_t)100); // Freq  = 500
	pwm_set(PWM_BUZZER, 0, 50);


The PWM Function is Causing corrupt stack. 

#### Steps to reproduce the issue
Setting up the Thread and sending Data with LoRaMac from Examples (Lorawan)
And enabling PWM on Pin.

#### Expected results
Working stackpointer (No Corruption)

#### Actual results

Stack pointer corrupted, reset to top of stack
 CFSR: 0x00001400
 HFSR: 0x40000000
 DFSR: 0x00000008
 AFSR: 0x00000000
EXC_RET: 0xfffffff1

#### Versions
Windows GCC / Nucleo64 Board

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210519/4f0cd069/attachment.htm>

More information about the notifications mailing list