LuisAfonso95 / TM4C123-Launchpad-Examples

41 stars 37 forks source link

Hi #3

Open hannerr opened 5 years ago

hannerr commented 5 years ago

I just read yout tutorial on pwm on your page, and I am tying to get this to run on my Tiva TM4C1294 leds. I have trouble getting the gpio pins right if I want to run the pwm on the led4.... Could you help me please? Tx hanna

LuisAfonso95 commented 5 years ago

LED4 is PF_0, correct? Were you trying to use PWM module or a normal timer? I assume it's the PWM module no timer output can be connected to PF_0.

If you are trying that I actually never added that to the website. It might be in the codes here though. Remember, to use PF_0 you need to unlock it, see https://sites.google.com/site/luiselectronicprojects/tutorials/tiva-tutorials/note---common-errors

hannerr commented 5 years ago

Hi, yes I put that in, but I don´t know what to put in here: / Configure PF1 as T0CCP1 Configure PF2 as T1CCP0 Configure PF3 as T1CCP1 /

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlDelay(3); GPIOPinConfigure(GPIO_PF1_T0CCP1); GPIOPinConfigure(GPIO_PF2_T1CCP0); GPIOPinConfigure(GPIO_PF3_T1CCP1); GPIOPinTypeTimer(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); instead? I have big trouble reading the manual and understanding this without examples... I´m very thankful for your help!

LuisAfonso95 commented 5 years ago

It's normal to be hard to understand in the beginning.

If you are using the TM4C1294 and check the datasheet under the timer section (13), in 13.2 Signal Description you will see that no timer output is connected to any of those pins. That's an example for the tm4c123 launchpad.

You can check examples for your board in TivaWare_C_Series-2.1.4.178\examples\boards\ek-tm4c1294xl, though there aren't any for what you are asking. If you try to understand things like checking which pins are connected to which functions, you can check other boards examples and adapt. (unlucky for you, it seems there aren't any for what you need).

You can use that example for say, PD0 which is connected to T0CCP0 on the tm4c1294. But you need to connect a LED. This way you avoid going into the PWM module, which is a different module than the timers. It's basically a advanced timer dedicated to generate PWM. It's a bit more complicated to use and no point on using it for LEDs.

hannerr commented 5 years ago

Thanks for your answer, I have to think about this, not sure I understand what you mean. Do I need to use another LED or port? I thought it was fixed. Maybe I´m just stuck, I´ll think and get back to you laters!

LuisAfonso95 commented 5 years ago

In the launchpad the LEDs are each connected to a pin. You cannot changed that. The pins used for the LEDs cannot be used by any timer. All 4 LEDs on the TM4C1294 launchpad won't work with a timer PWM.

So I suggest you instead a external LED (with resistor of course) and connect it to PD0 which is connected to T0CCP0.

Good luck!

hannerr commented 5 years ago

Ok, thanks for your advice, but I have to implement pwm on the led 4 as a homework. it seems strange I got this as an assignment if it isnt possible?

LuisAfonso95 commented 5 years ago

well it is possible. Just not with the general purpose timers. You would need to use the PWM module, check out in the datasheet "23 Pulse Width Modulator (PWM)" it should show you that it can use PF0.

I am assuming you're speaking of this launchpad? https://forum.43oh.com/uploads/monthly_04_2014/post-3200-14264605408006.jpg

Again, if you check PF0 which is the pin connected to LED4, it does not have timer output, but it does have PWM module (M0PWM0). image

Aaaah. I knew I made something with PWM module and uploaded it. This is a library for TM4C, not sure if I made it to be used with energia but there you can see the module being used. https://github.com/LuisAfonso95/Tiva-Custom-libraries-APIs/tree/master/DRV8833

hannerr commented 5 years ago

Hi Luis, Yes this is the Launchpad I am using, I will check out your code in the evening. I am very grateful for your help, as you can see I am quite confused with all the new stuff ^^

hannerr commented 5 years ago

One more thing...You can check examples for your board in TivaWare_C_Series-2.1.4.178\examples\boards\ek-tm4c1294xl, I cant seem to find these on google?

LuisAfonso95 commented 5 years ago

It's normal. In the beginning I bothered people every week because it was my first time programming a MCU without high abstraction. You seem to have erased the question about the tivaware examples? You probably have tivaware (with maybe another version?) in your computer. Inside there any many useful things like those examples.

On google you maybe can find TI resource explorer cloud, though I doubt there are many examples for TM4C there. Also I don't think TM4C team has a public github, unlike some newer TI teams.

hannerr commented 5 years ago

I didnt erase the question, its still here in my view ^^ I´m using CodeComposer for mac with a Library issued from my university....but I´ll see what google gives me...some examples would be great