Tool/software:
I seem to have some sort of problem writing a one to Bit 0 of my Data Register and I can't find the fault. 9 gets changed to 8 and 3 gets changed to 2. When I correct it to an even number it shows up fine in my Debug Watch window. I rechecked my pin setup lines for PortE and I do believe they are correct. I also swapped out Tive Lunchpad Boards but damn, nothing works. Source code attached. Thank you.
/* Stepper.c Driving stepper in C using registers by addresses */ /* This program will start with a simple rotation of a stepper and get refined to include keypad input and LCD output .*/ /*We are going with Port E pins: 9 >PE0, 8 >PE1, 7 >PE2 and 6 >PE3 because their default is GPIO */ /* PORTE data register */ #define PORTEDAT (*((volatile unsigned int*)0x400243FC)) // DS pg 662, GPIO Port E (APB) base: 0x4002.4000 // 3FC is needed to write to all 8 bits of Data Register at once. SEE Text pg 28 /* PORTE data direction register , 3FC is 0B001111111100 masked bits 9:2 means set all Port E outputs */ #define PORTEDIR (*((volatile unsigned int*)0x40024400)) // DS pg 662, GPIO Port E (APB) base: 0x4002.4000 */ /* PORTF digital enable register */ #define PORTEDEN (*((volatile unsigned int*)0x4002451C)) // DS pg 683, GPIO Port E (APB) base: 0x4002.4000 //0x51C is the offset for GPIODEN /* run mode clock gating register */ #define RCGCGPIO (*((volatile unsigned int*)0x400FE608)) // DS pg 340. Clock gate. base: 0x400F.E000 //Bit 4 will be sey to enable the clock on Port E. /* coprocessor access control register */ #define SCB_CPAC (*((volatile unsigned int*)0xE000ED88)) // Coprocessor access priviledge void delayMs(int n); /* function prototype for delay, argument is delay in ms */ int main(void) { /* enable clock to GPIOE at clock gating register */ RCGCGPIO |= 0x10; // RCGCGPIO Or'd with 0x10 or 0b0001 0000 meaning bit 4 enables Port E clock /* set PORTE pin3-1 as output pins */ PORTEDIR = 0x0E; // 0x0E is 0b0000 1110 Sets DIR on PortE to output. /* set PORTE pin3-1 as digital pins */ PORTEDEN = 0x0E; // 0x0E is 0b0000 1110 PORTEDAT=0X00; int x; for (x = 0; x < 360; x++) { PORTEDAT = 0X09; delayMs(500); PORTEDAT = 0X0C; delayMs(500); PORTEDAT = 0X06; delayMs(500); PORTEDAT = 0X03; delayMs(500); } } /* delay n milliseconds (16 MHz CPU clock) */ void delayMs(int n) { int i, j; for(i = 0 ; i < n; i++) for(j = 0; j < 3180; j++) {} /* do nothing for 1 ms */ } /* This function is called by the startup assembly code to perform system specific initialization tasks. void SystemInit(void) { Grant coprocessor access This is required since TM4C123G has a floating point coprocessor SCB_CPAC |= 0x00F00000; } */