SAMD10 - Problems with the HAL PWM Driver (Callback)

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Guys and ladies,

 

i am really new in the ARM Topic and the HAL Driver allready broke my head :-D Not yet but it will.

 

I want do use the PWM driver to generate a single shot PWM signal. The next step will be to build an Bit banging Signal to controll WS2812b LEDs.

I used an SAMD10 with the internal 8MHz CLK, for the first steps I configure the CPU CLK to 8MHz and the Timer TC2 CLK to 1MHz.

For the moment it#s not interesting, if the project will work an 8MHz, because I can use an external CLK to speed this up.

 

I used an Callback like this:

 

void pwmPeriodCallback(const struct pwm_descriptor *const descr)
{
    hri_tc_clear_CTRLA_ENABLE_bit(descr->device.hw);
}

int main(void)
{
    /* Initializes MCU, drivers and middleware */
    atmel_start_init();
    
    NVIC_EnableIRQ(TC2_IRQn); // Enable ISR
    pwm_register_callback(&PWM_0, PWM_PERIOD_CB, pwmPeriodCallback); // link the disable function
    
    // pwm settings
    pwm_set_parameters(&PWM_0, 999, 640);
    pwm_enable(&PWM_0);
    
    //wait until callbacks kill enable Bit
    while (hri_tc_get_CTRLA_ENABLE_bit(&PWM_0.device.hw));

    /* Replace with your application code */
    while (1);

}

 

The callback happend, but then on the Signal WO[1] a small peak comes up lik this:

 

Signal WO[1] at the top and on the bottom Signal WO[0] of the TC2 Driver.

 

 

 

 

 

 

I set up the hole project with the HAL driver, only the Clear funtion of the Enable PWM is from the hri function. Because i tryed to check if the problem comes from the high level programming.

 

Can somebody of you explain me, what the happend there ?

Is it possible to drive a signle shot method ?

 

Or should i use a timer and make really root bit banging per GPIO Pin ?

 

Thanks in advanced !!

 

Your Drops93

 

 

Brandnew Freshman

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it may be that the timer is setup so when it reaches TOP it set the output WO[x] and when it reaches bottom it clears it.

Last Edited: Fri. Sep 24, 2021 - 10:39 AM