Skip to main content
SRedd.5
Senior III
July 22, 2023
Solved

Systick time missing

  • July 22, 2023
  • 14 replies
  • 5822 views

I am running the motor control workbench B-G431B-ESC1 board. The systick fires at every 2K frequency as per the user manual and the waveform matches when i toggle, but the problem is sometimes it misses as shown

SRedd5_0-1689998582490.png

I want to debug and find out why it misses those timings in between. Please suggest how do i find out? I am also running CAN in parallel at 500KBPS.

    This topic has been closed for replies.
    Best answer by SRedd.5

    I modified the algorithm of CAN and behavior is ok now, i mean i transmit 3 messages at one time, after 1 sec another 3 messages with total of 12 messages

    1st sec -> 3messages

    2nd sec -> 3 messages

    3rd sec -> 3 messages

    4th sec -> 3 messages

    repeat like this.

    14 replies

    Karl Yamashita
    Principal
    July 25, 2023

    You need to exit the systick quickly when it interrupts so other interrupts can fire, as well as the systick itself. In your systick, set a flag. In a main while loop check the flag and then call your 3 tasks

    MC_RunMotorControlTasks();
    CAN_Task();
    HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_12);

    If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
    SRedd.5
    SRedd.5Author
    Senior III
    July 27, 2023

    I have tried this once but seem to be complete misbehavior, i will try again.

    Johi
    Senior II
    July 25, 2023

    , I still wonder if you have reflected on the thought of driving your I/O directly with a timer unloading your MCU and guaranteeing timing as per hardware? ARM/STM32 is designed for that approach and then you are 100% sure that timing is correct. If it takes too much time to solve the issue using interrupt priorities and the like, then for sure you risk that your final solution will not have maximal robustness as environmental conditions can vary. You can change frequency and duty cycle from your main loop but leave the heavy lifting to the hardware timer driving the I/O.

    SRedd.5
    SRedd.5Author
    Senior III
    July 27, 2023

    I have to study about this i never done it before. I will give a try.

    Johi
    Senior II
    July 27, 2023

    See below example for 1 Hz, you should be able to to take it from there.

    SRedd.5
    SRedd.5Author
    Senior III
    July 27, 2023

    The problem is it is motor control application so i use all the PWM channels, hence i cannot use the method you suggested for driving the GPIO's.

    SRedd.5
    SRedd.5AuthorBest answer
    Senior III
    September 24, 2023

    I modified the algorithm of CAN and behavior is ok now, i mean i transmit 3 messages at one time, after 1 sec another 3 messages with total of 12 messages

    1st sec -> 3messages

    2nd sec -> 3 messages

    3rd sec -> 3 messages

    4th sec -> 3 messages

    repeat like this.