Hey!
Im doing the LM4F120 workshop and i was trying to get the ButtonsPoll function to work in order to change the colour of the LED and after a while i got it working. After that i thought i could use the other push button to toggle the intensity of the LED. I tried to do this by using the RGBIntensitySet function, but when i include it in the code it gets stuck in the FaultISR loop. I can't figure out why this happens. Can someone help me please?
I could identify two problems. On is that when i use two ButtonsPoll the code will compile but when i run the code nothing happens when i press any of the buttons. If would comment the second ButtonsPoll the code run and i can change the colour by pressing the right button. This is when the RGBIntensitySet is commented aswell. The second problem is that if i uncomment the RGBIntensitySet i get stuck in the FaultISR loop.
I might have made more misstakes here but i can't figure out how this works.
"
Here is my code:
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "drivers/buttons.h"
#include "drivers/rgb.h"
int main(void)
{
unsigned char ucStateR;
unsigned char ucDeltaR;
unsigned char ucStateL;
unsigned char ucDeltaL;
float intensity = 0.5;
int LED = 2;
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
ButtonsInit();
while(1)
{
SysCtlDelay(10000);
ucStateR = ButtonsPoll(&ucDeltaR,0);
ucStateL = ButtonsPoll(&ucDeltaL,0);
if(BUTTON_PRESSED(LEFT_BUTTON, ucStateL, ucDeltaL))
{
intensity = intensity + 0.25;
if(intensity>1.25)
{
intensity = 0;
}
}
if(BUTTON_PRESSED(RIGHT_BUTTON, ucStateR, ucDeltaR))
{
RGBIntensitySet(intensity);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, LED);
SysCtlDelay(2000000);
if (LED == 8) {LED = 2;} else {LED = LED*2;}
}
}
}