Author Topic: Nuvoton: MS51FB9AE PWM retains previous state after turning off (Solved)  (Read 1857 times)

0 Members and 1 Guest are viewing this topic.

Offline Ashwin619Topic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: in
Hello everyone,

I am working on a design where I need to drive a piezo buzzer (@2.7kHz, 50%) at some regular intervals for a certain duration. The PWM seems to work fine whenever I start it, although it retains its previous state whenever I turn it off. I want the default state to be LOW, however there seems to be no way to configure it as such through any particular register (might have missed it).

A couple of possible solutions to this would either be to turn off the PWM by writing a LOW on the pin (unlikely this would work) OR make the duty 0 rather than turning off. Both of these methods don't seem to be a good way of doing it.

I am attaching the PWM scope waveform and the piece of code that I am using to achieve this. I would appreciate if someone could shed some more light on this.









Let me know if some more details are required regarding the macros that are being used for peripheral initialization.

Regards,
Ashwin619.
« Last Edit: October 16, 2023, 09:41:32 am by Ashwin619 »
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 2351
  • Country: au
Re: Nuvoton: MS51FB9AE PWM retains previous state after turning off
« Reply #1 on: October 09, 2023, 03:18:34 am »
A couple of possible solutions to this would either be to turn off the PWM by writing a LOW on the pin (unlikely this would work) OR make the duty 0 rather than turning off. Both of these methods don't seem to be a good way of doing it.
Why do they 'don't seem to be a good way of doing it. ' ?
If you stop the clock to a PWM module it will freeze.
If you disable the PWM module, it will revert the port to the default state, on 8051 that's usually 1, so you simply write 0 if you want 0.
 
The following users thanked this post: Ashwin619

Offline Ashwin619Topic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: in
Re: Nuvoton: MS51FB9AE PWM retains previous state after turning off
« Reply #2 on: October 09, 2023, 04:21:46 am »
Hello PCB.Wiz,

I agree with your statement but in order to implement that Ill probably have to change the pin configuration from that of a PWM to a GPIO by changing this bit ->



Note:- I have tried doing the above thing by writing a LOW on the PWM pin after making it go in the idle state although that didn't seem to work as expected. I believe Ill have to do the above changes in order to implement it. Let me know what do you think ?

Regards,
Ashwin619.
 

Offline Ashwin619Topic starter

  • Regular Contributor
  • *
  • Posts: 62
  • Country: in
Re: Nuvoton: MS51FB9AE PWM retains previous state after turning off
« Reply #3 on: October 16, 2023, 09:38:08 am »
I have used the PMD (Pin masking data) and PMEN (Pin masking enable) to solve the above issue. Had found out a couple of days ago. Don't know how I missed it  |O
« Last Edit: October 16, 2023, 09:40:43 am by Ashwin619 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf