I've been trying to change my driver for a ranging system, as I was updating to the newest firmware, where the LPS is used.
In my old driver version I used to take the ressources of CPPM-Driver as my range driver.
Everything worked so far, see my previous thread.
Now I needed to change the ressources, as the old ones are now used by CPPM-system.
Indeed I changed my used Timer and GPIO-Pin, to TIM2 and PA5 as I want to capture PWM-Signals.
I changed everything according to the following graphic from the STM32-Datasheet:

When firing up my firmware, I get
Code: Select all
SYS: The system resumed after watchdog timeout [WARNING]
SYS: Assert failed at src/lib/FreeRTOS/portable/GCC/ARM_CM4F/port.c:736
My code for initialising the timer and gpio follows:
Code: Select all
void pwmInit(void) // PWM-Funktion einrichten auf PIN MOSI (PA6, Funktion in neuer Firmware für LPS auf Konflikt checken)
{
#define PWM_TIMER TIM2
#define PWM_TIMER_RCC RCC_APB1Periph_TIM2
#define PWM_TIMER_CH_Init TIM_OC1Init
#define PWM_TIMER_CH_PreloadConfig TIM_OC1PreloadConfig
#define PWM_TIMER_CH_SetCompare TIM_SetCompare1
#define PWM_GPIO_RCC RCC_AHB1Periph_GPIOA
#define PWM_GPIO_PORT GPIOA
#define PWM_GPIO_PIN GPIO_Pin_5
#define PWM_GPIO_SOURCE GPIO_PinSource5
#define PWM_GPIO_AF GPIO_AF_TIM2
#define PWM_TIM_PRESCALER (84 - 1)
#define PWM_MIN_PPM_USEC 1150
#define PWM_MAX_PPM_USEC 1900
// Deklarieren von Init Structures
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; // Time Base Init structure definition
TIM_ICInitTypeDef TIM_ICInitStructure; // Input Capture Init structure definition
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/*Enable clock for GPIOB*/
RCC_AHB1PeriphClockCmd(PWM_GPIO_RCC, ENABLE); // GPIOClock einschalten (1)
RCC_APB1PeriphClockCmd(PWM_TIMER_RCC, ENABLE); // TimerClock einschalten
// Configure the GPIO to be the timer (TIM14) input [MOSI-Pin]
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = PWM_GPIO_PIN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_Speed = GPIO_Medium_Speed;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(PWM_GPIO_PORT, &GPIO_InitStructure);
GPIO_PinAFConfig(PWM_GPIO_PORT, PWM_GPIO_SOURCE, PWM_GPIO_AF);
// Time base configuration. 1us tick.
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Prescaler = PWM_TIM_PRESCALER*10; //1 µS
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(PWM_TIMER, &TIM_TimeBaseStructure);
// Setup input capture
TIM_ICStructInit(&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;
TIM_ICInit(PWM_TIMER, &TIM_ICInitStructure);
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
captureQueue = xQueueCreate(64, sizeof(uint32_t));
// Enables or disables the specified TIM interrupts
TIM_ITConfig(PWM_TIMER, TIM_IT_Update | TIM_IT_CC1, ENABLE);
// Enables or disables the specified TIM peripheral
TIM_Cmd(PWM_TIMER, ENABLE);
}
Any thoughts on this would be very useful.
Thanks in advance!
Greets,
Che.