Hi, I am using the EduBase ARM Trainer together with the LaunchPad. According to one of the diagrams the LEDs are connected to PORT B but only PB0 is turning on:
Here is the code I have, I'm running this on Keil uVision5:
Lab4_2.h
*******************************************************
#include <stdint.h> #include <stdbool.h> #define SYSCTL_RCGC2_R (*((volatile uint32_t*)0x400FE108)) #define GPIO_PORTB_DATA_R (*((volatile uint32_t*)0x400053FC)) #define GPIO_PORTD_DATA_R (*((volatile uint32_t*)0x400073FC)) #define SYSCTL_RCGC2_GPIOB 0x00000002 // Port B Clock Gating Control #define SYSCTL_RCGC2_GPIOD 0x00000008 // Port D Clock Gating Control
Lab4_2.c
*******************************************************
#include "Lab4_2.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" int main(void) { uint32_t ui32Input; bool res; // Set up the clock SysCtlClockSet(SYSCTL_SYSDIV_10|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); // Enable the GPIO PROTB & PORTD SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOB|SYSCTL_RCGC2_GPIOD; // Set PB0-PB3 as an output pins GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_3); GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2); GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_1); GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0); // Set PD0-PD3 as an input pin GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_3); GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_2); GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1); GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_0); // Check whether both ports are ready to be accessed res = SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB) | SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD); if (res) { while(1) { ui32Input = GPIO_PORTD_DATA_R; // If DIP-SW1 is pressed turn on LED if ((ui32Input & 0x8) == 0x8) { GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, 0x1); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1, 0x1); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2, 0x1); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_3, 0x1); SysCtlDelay(500000); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, 0x0); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1, 0x0); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2, 0x0); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_3, 0x0); SysCtlDelay(500000); } } } }
Is there something I'm missing?
Thank you.