Page 1 of 2

Percent power I/O pin

Posted: Mon Sep 13, 2010 12:13 pm
by jokes304
I was trying to control the voltage that is output using an general I/O pin. Are there any commands that can help me do this?

Re: Percent power I/O pin

Posted: Mon Sep 13, 2010 12:26 pm
by Chris Ruff
challenging.....

what is providing power?
is the single line an input or an output?
is the single line analog or digital in nature?

is there a 305th joke?

Re: Percent power I/O pin

Posted: Mon Sep 13, 2010 12:28 pm
by jokes304
For now it will be dimming a LED for a calibration system. It will be an output.

Re: Percent power I/O pin

Posted: Mon Sep 13, 2010 12:32 pm
by lgitlitz
Dimming LEDs should be done with pulse width modulation. Which product are you using? The MOD5213 has PWM peripherals, the other products can do PWM using the hardware timers.

-Larry

Re: Percent power I/O pin

Posted: Tue Sep 14, 2010 1:27 pm
by jokes304
I am using the 5234. Do you now of any tutorials on Pulse Width Modulation using the MOD 5234?

Re: Percent power I/O pin

Posted: Tue Sep 14, 2010 2:45 pm
by Ridgeglider
The 5234 supports PWM directly from the eTPU unit.

See http://www.netburner.com/downloads/mod5 ... ppNote.zip
unzip it and go to: eTPUAppNote/Examples/eTPU_PWM/main.cpp
Be sure to read the APPNOTE-MOD5234-eTPU-R1p1.pdf in the main eTPUAppNote directory first.

The eTPU can run 15 or 16 parallel channels of PWM depending on the board rev.

With a little more work inside an ISR, you can also use the PIT or DMA timers to create these waveforms. See:
http://www.netburner.com/downloads/mod5 ... -timer.pdf
or:
http://www.netburner.com/downloads/mod5 ... ppNote.pdf

Re: Percent power I/O pin

Posted: Tue Sep 14, 2010 3:09 pm
by Ridgeglider
For more description of the underlying PWM function, see
http://cache.freescale.com/files/32bit/ ... umentation

Re: Percent power I/O pin

Posted: Tue Sep 14, 2010 10:26 pm
by v8dave
This works well from the eTPU. I have used the following code to control an LED backlight on a TFT display using an NCP5005 driver IC.

I used this to configure the eTPU IO for PWM

fs_etpu_pwm_init(GPIO_LEDBL, FS_ETPU_PRIORITY_MIDDLE, 50000, 5000, FS_ETPU_PWM_ACTIVEHIGH, FS_ETPU_TCR1, etpu_a_tcr1_freq);

GPIO_LEDBL being the eTPU output you are going to use.

Use this to set the duty and your brightness.

fs_etpu_pwm_duty(GPIO_LEDBL, Brightness * 100);

I found that the Brightness setting for the driver I was using the value was between 44 and 100 for min and max.

Dave...

Re: Percent power I/O pin

Posted: Fri Jan 21, 2011 11:59 am
by jokes304
I seem to have encountered another problem with this. I was able to get the PWM working on a few of the eTPU pins but not on all 16. About half of them remain on and at full power no matter what I do. Is there a way to reset the pin to a default off to try to redo it, or any other ideas?

Re: Percent power I/O pin

Posted: Mon Jan 24, 2011 2:46 pm
by lgitlitz
There were some issues with the Freescale ETPU functions that arise when switching between different pun functionality. I am not positive but I believe one of the PWM functions may have an issue here. The work around here is to manually initialize the eTPU with the PWM functions and not to change their functionality after initialization. The normal eTPUInit() function initializes the eTPU, sets all the pins to GPIO input and starts the eTPU. You should instead use the following:
MOD5234_etpu_init();
MOD5234_etpu_start();
// now initialize all of your eTPU pins to be PWM
You can also try initializing th ePWM pins before you start the eTPU but it should be after you call MOD5234_etpu_init(). You should always be checking the return values of functions, especially the initialization one, to see if you are getting any errors.

The newest beta release, 2.5.1 or higher, have an update to the eTPU driver. There was a bug that prevented switching to a few functions in some sets. Since you can get PWM to work on some pins this would not be an issue affecting you. The function sets have also all been upgraded to the newest versions of the Freescale binary sets which may fix your issue. All the automotive functions and their eTPU set has been added. eTPU set4 has been changed to the proper processor set so it can now be used, Freescale was incorrectly distributing a version to large for the MCF5234 in their application note.