Using counter_set_top_value() to call callback function is not working.

Hello everybody!

It's my first question and I'm new at mcu programming. I hope for your understanding!

I have a task:
count seconds using a counter and display them on a LED matrix (I attached the code only for initialization and places with the counter and its callback function) at the moment I want to use the following logic:
the counter overflows, the callback function is called, a variable is incremented in it, which, when counting the seconds passed, is multiplied by 512 (since the counter is 24 bits, and the frequency is 32768 Hz) and added to the time that is currently saturated

But now it doesn't work. i can't see printk from counter_callback in rtt viewer

Another code works. Work queue works. Seconds that counted in counter less than 512 I can display

 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/counter.h>
#include <zephyr/device.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/gap.h>
//INITIALIZATION FUNCTIONS
//int counter_init(void); //FUNCTION TO INIT COUNTER
int bt_le_init(void); //FUNCTION TO INIT BLE
int number_length(int num); //FUNCTION TO CALCULATE THE LENGTH OF THE NUMBER OF SECONDS ELAPSED
void number_to_arr(uint32_t num, uint8_t *arr); //FUNCTION TO DIVIDE NUMBER TO DIGITS IN ARRAY
void array_remove(const uint8_t *arr_initial, uint8_t *arr_final, uint8_t size, uint8_t index); //FUNCTION TO REMOVE ELEMENT FROM ARRAY
void button_isr(const struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pins); //BUTTON ISR PROTOTYPE
//static void counter_top_callback(const struct device *dev, void *user_data); //COUNTER ISR PROTOTYPE
void k_work_q_seconds_display(struct k_work *work); //K_WORK_Q FUNCTION TO DISPLAY DIGITS
void seconds_display(void); //FUNCTION TO DISLAY TIME
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX