- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I have a simple project with a pwm timer driving direct a GPIO out pin.
I have a motor driver on this pin.
My problem is when the chip power up the pin state is low, which means that the motor driver is at max speed. The max out put is there until i initilze the PWM timer.
How can i set the pins so they allways start up in tristate until at initialize them ?
Project added
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have a look in the generated source code for your pin that you have connected to the output of your PWM (e.g. If the pin is called PWM_Pin then have a look at PWM_Pin.h)
There will be a bunch of #define statements in there of the format:
#define PWM_Pin_DM_ALG_HIZ (0x00u) /**< \brief High Impedance Analog */
#define PWM_Pin_DM_DIG_HIZ (0x01u) /**< \brief High Impedance Digital */
#define PWM_Pin_DM_RES_UP (0x02u) /**< \brief Resistive Pull Up */
#define PWM_Pin_DM_RES_DWN (0x03u) /**< \brief Resistive Pull Down */
#define PWM_Pin_DM_OD_LO (0x04u) /**< \brief Open Drain, Drives Low */
#define PWM_Pin_DM_OD_HI (0x05u) /**< \brief Open Drain, Drives High */
#define PWM_Pin_DM_STRONG (0x06u) /**< \brief Strong Drive */
#define PWM_Pin_DM_RES_UPDWN
You can use the API PWM_Pin_SetDriveMode(uint8 mode) using one of the above #define for mode to set the drive mode of your PWM output pin to whatever you need.
You can set the drive mode and initial drive state for that pin in the Pin Component, which is what it will default to when your code starts up, and then you can use PWM_Pin_SetDriveMode(uint8 mode) to change it to whatever you need once you've initialised your PWM
Cheers,
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @EsFr_4600111 ,
I regret to convey that your issue is not very clear to me. Can you please attach your project here? This will help us understand the problem properly and get back with a solution.
Best Regards,
Aashita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Aashita
can you help me solve this issue?
Br
Esben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Esben, when the PSoC resets, the pins stays in a HighZ state till it gets initialized. Ideally you want to pull up the pin externally to avoid this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes when its in reset mode the PIN is in HighZ state, but as soon I release the reset its pulling the pin down until i call pwm_Start();
The problem is only when i have it connected on a PWM timer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, I see the problem. During the initialization, that pin is configured to be Open-Drain Drives Low, which happens in the pre-main code. The output is driven LOW because the hardware is not configured yet.
What you can do is to configure the pin in the TopDesign to be High Digital Z and only set the drive mode to Open-Drain Drives Low after initializing the PWM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you have a look in the generated source code for your pin that you have connected to the output of your PWM (e.g. If the pin is called PWM_Pin then have a look at PWM_Pin.h)
There will be a bunch of #define statements in there of the format:
#define PWM_Pin_DM_ALG_HIZ (0x00u) /**< \brief High Impedance Analog */
#define PWM_Pin_DM_DIG_HIZ (0x01u) /**< \brief High Impedance Digital */
#define PWM_Pin_DM_RES_UP (0x02u) /**< \brief Resistive Pull Up */
#define PWM_Pin_DM_RES_DWN (0x03u) /**< \brief Resistive Pull Down */
#define PWM_Pin_DM_OD_LO (0x04u) /**< \brief Open Drain, Drives Low */
#define PWM_Pin_DM_OD_HI (0x05u) /**< \brief Open Drain, Drives High */
#define PWM_Pin_DM_STRONG (0x06u) /**< \brief Strong Drive */
#define PWM_Pin_DM_RES_UPDWN
You can use the API PWM_Pin_SetDriveMode(uint8 mode) using one of the above #define for mode to set the drive mode of your PWM output pin to whatever you need.
You can set the drive mode and initial drive state for that pin in the Pin Component, which is what it will default to when your code starts up, and then you can use PWM_Pin_SetDriveMode(uint8 mode) to change it to whatever you need once you've initialised your PWM
Cheers,
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mike
Very nice
Thank you very much, this solves my start up problem.
Br
Esben