Jump to content

Help: How to Simulate PWM on Pin PA_6 (Stellaris)?

Recommended Posts

I'd like to use a BoosterPack initially designed for the LaunchPad MSP430 but on the LaunchPad Stellaris / Tiva.


Problem is, the BoosterPack uses PWM on pin P2_1 (MSP430). Corresponding pin on Stellaris

is PA_6 but PA_6 isn't PWM in standard on Energia.


How to simulate PWM signal on pin PA_6 Stellaris with Energia and be able to start and stop it?


Requirements are fairly basic: 50% duty cycle, 100~300KHz, square wave.


Thank you!

Link to post
Share on other sites

Are you using all the nearby pins that have PWM?  If not, could just bridge another pin to the connector (e.g. PD3)


Sounds like the problem in that other thread is with the upload program.  


So could get around it by using openOCD as suggested there, or if you have access to Windows, could try to see if you can upload the program with LM Flash.



To start/stop - either Enable/Disable interrupts, or have the ISR check a variable and only toggle the pin if variable set.

Link to post
Share on other sites


With the proposed approach starting and stopping the "PWM" is simple: start and stop the timer - use driverlib functions TimerEnable() and TimerDisable(). Want to stop on particular level (Hi/Lo)? use a flag to stop on that particular event.


As for TimerIntRegister - you are not forced to used this function. If you need to use this, then check the linker to provide in RAM a section vtable, aligned at 1024, declared in interrupt.c file. Check also the .map file, the section should be placed starting at 0x20000000, and the linker is smart enough not to put it there if not used. 


Link to post
Share on other sites
  • 3 weeks later...

 You can try to use the timer (if you see how its made a PWM with some comparators, the same method can be used here) so you can make a software controlled PWM, on every pin you want not only on the hardware pins 


here is a sample code, if you need more help i will try to explain you the code (with pictures :P)



You need some code for input to change the variable, so you can set the duty cycle.

If you see the signal from the timer, its like a sawtooth signal, if you make the code right so you can change the value of n, you can set the middle of the timer, you can set the point when it will rise and fall, so because its a endless loop, it will every time set the new value, and you can set the right value....


I dont know if you can understand me what im trying to tell you (it some bit difficult to me to explain this in this way), sorry if you dont understand :P

Here is the sample code, insert some code to make some "borders" in witch the variable can go up and down, dont make it so it can go to endless

while (1) {
for (i=1;i<=100;i++)
if (i<n)
{ GPIO_PORTJ_DATA = 255; }
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...