SAMS70Q21 PWM controller driver - how to change period & duty cycle of ONE channel?

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

I have a design with SAMS70Q21AN which uses one PWM controller to generate two PWM signals (channel 2 and 3). I have generated the firmware project & drivers using Atmel START.

 

Using one channel worked fine but now that I added the 2nd channel it seems I cannot control each channel separately. For example, the function _pwm_set_param() (in hpl\pwm\hpl_pwm.c) seems to apply duty cycle and period to ALL channels even though the hardware supports individual control:

 

void _pwm_set_param(struct _pwm_device *const device, const pwm_period_t period, const pwm_period_t duty_cycle)
{
    uint8_t i;
    const struct _pwm_cfg *cfg;
    
    ASSERT(device && (duty_cycle < period));
    
    cfg = _pwm_get_cfg(device->hw);
    
    for (i = 0; i < cfg->ch_num; i++) {
        hri_pwm_write_CDTYUPD_reg(device->hw, cfg->ch[i].index, duty_cycle);    // Duty cycle & period applied to ALL channels!?
        hri_pwm_write_CPRDUPD_reg(device->hw, cfg->ch[i].index, period);
        }
}

 

So how is firmware supposed to change period and/or duty cycle of one single channel of the 4-channel PWM controller?

 

Some version information from atmel_start_config.atstart:
versions:
api: '1.0'
backend: 1.5.122
commit: 820baecf7dd115d94b0d42ee3b0b9d6ba2da7113
content: 1.0.1498
content_pack_name: acme-packs-all
format: '2'
frontend: 1.5.1826
board:
identifier: CustomBoard
device: ATSAMS70Q21A-AN

 

Atmel kits: 7.0.122
ASF version: 3.40.0.1184
Atmel Studio: 7.0.1931
Windows 7 Professional
GCC

/Jakob Selbing

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

Well, I submitted a new support case at Microchip. While waiting for response I tried simply modifying the existing function to allow passing the PWM channel as parameter and modifying only those settings, which does seem to work properly. But I don't like modifying the generated code... :/

/Jakob Selbing