Monday, July 27, 2015

Phase 1: Complete




blogger.com actually allows you to upload a video. cool. first time trying out this feature .. without specifying a youtube link.

video above is the completion of phase 1. was out on sick day today ... took the time to bug hunt after I got some sleep. system/pll/systick/interrupts/gpio all configured. but there were issues:

found a bug with my interrupt vector table initialization for the 256 positions (the maximum possible) though the lpc17xx only provides 40 peripheral interrupts for a total of 56 when you include the 16 core exceptions.

I was stupidly overwriting portions of the code in SRAM. this bug was easy to catch  ... it was a silly mistake because I actually wanted to cover the best case scenario and reserve the first 1k for the IVT.
then I later decided what the hell thats a waste of space when only 224 bytes will be used I could save almost 700 bytes to use for program memory or a thread stack

in my Makefile now specifying
-fno-inline
and
-fno-implement-inlines

to decrease code size bloat. although I have 512kb of flash ROM, i am loading the code into the 64k of SRAM to make debugging easier. in flash rom i would be limited to 4 or 6 hardware break points verses an unlimited amount when I load into SRAM ... so I am sticking to SRAM for now, but to pull that off I have to stick to non macro functions to keep the size of the program in check.


changed NVIC pre-rempt priority grouping to 2. Allowing me to use all 32 interrupt priority levels.

Configured exceptions 4 + 5 + 6   to priority level 0
                                     11+14        to priority level 1
                                     15 (systick)to priority level 2
all peripheral interrupts will start from priority level 3 (highest)  to 31 (lowest)

Absolutely no interrupt nesting ... keep interrupts small and simple. The NVIC does handle that feature (nesting and tail chaining) in hardware  ... a big plus

bug in failing to call
Calling  NVIC_EnableIRQ(15) after setting up systick registers. Dumped the interrupt SET/ENA registers and realized it wasnt set

Found a bug in how lpcopen' Chip_GPIO_GetPinState() works. Decided to read the pin directly and write it out to toggle the keep-alive-LED



//wdTemp = Chip_GPIO_GetPinState(LPC_GPIO1, LPC_LED_PORT, LPC_LED_PIN);
//Chip_GPIO_SetPinState(LPC_GPIO1, LPC_LED_PORT, LPC_LED_PIN, wdTemp);

wdTemp = (((LPC_GPIO1->PIN) >> LPC_LED_PIN) & 0x1);
wdTemp ^= 0x1;
if(wdTemp == 0)
        (LPC_GPIO1->CLR) = (1 << LPC_LED_PIN); 
else
        (LPC_GPIO1->SET) = (1 << LPC_LED_PIN); 




Phase 2 begins now. Need to write a useful serial terminal monitor program to ease communication with this board.

2:40am ... powering down ... engaging sleep mode routines

No comments:

Post a Comment