Percent power I/O pin

Discussion to talk about software related topics only.
jokes304
Posts: 23
Joined: Wed Jun 02, 2010 12:13 pm

Percent power I/O pin

Post 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?
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: Percent power I/O pin

Post 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?
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
jokes304
Posts: 23
Joined: Wed Jun 02, 2010 12:13 pm

Re: Percent power I/O pin

Post by jokes304 »

For now it will be dimming a LED for a calibration system. It will be an output.
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: Percent power I/O pin

Post 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
jokes304
Posts: 23
Joined: Wed Jun 02, 2010 12:13 pm

Re: Percent power I/O pin

Post by jokes304 »

I am using the 5234. Do you now of any tutorials on Pulse Width Modulation using the MOD 5234?
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: Percent power I/O pin

Post 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
Ridgeglider
Posts: 513
Joined: Sat Apr 26, 2008 7:14 am

Re: Percent power I/O pin

Post by Ridgeglider »

For more description of the underlying PWM function, see
http://cache.freescale.com/files/32bit/ ... umentation
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: Percent power I/O pin

Post 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...
jokes304
Posts: 23
Joined: Wed Jun 02, 2010 12:13 pm

Re: Percent power I/O pin

Post 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?
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: Percent power I/O pin

Post 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.
Post Reply