From 70af5bce83f6a646188481179cf97a5e31d4a9ca Mon Sep 17 00:00:00 2001 From: Dan White Date: Fri, 7 Sep 2012 20:20:28 -0500 Subject: [PATCH] update --- msp4th/ldscript_ns430 | 3 ++ msp4th/main.c | 79 ++++++++++++++++++++++--------------------- msp4th/mkfile | 49 +++++++++++++++++++-------- msp4th/msp4th.c | 78 +++++++++++++++++++++++------------------- 4 files changed, 121 insertions(+), 88 deletions(-) diff --git a/msp4th/ldscript_ns430 b/msp4th/ldscript_ns430 index 4c16343..fdee3f9 100644 --- a/msp4th/ldscript_ns430 +++ b/msp4th/ldscript_ns430 @@ -118,6 +118,8 @@ SECTIONS . = ALIGN(2); _edata = . ; } > data + PROVIDE (__data_load_start = LOADADDR(.data) ); + PROVIDE (__data_size = SIZEOF(.data) ); /* Bootloader. */ .bootloader : { @@ -148,6 +150,7 @@ SECTIONS PROVIDE (__bss_end = .) ; _end = . ; } > data + PROVIDE (__bss_size = SIZEOF(.bss) ); .noinit SIZEOF(.bss) + ADDR(.bss) : { PROVIDE (__noinit_start = .) ; diff --git a/msp4th/main.c b/msp4th/main.c index 55bad0b..1820574 100644 --- a/msp4th/main.c +++ b/msp4th/main.c @@ -12,43 +12,44 @@ int main(void){ - PAPER = 0x0030; - PAOUT = 0x0000; - PAOEN = 0x0010; // set data direction registers - - init_msp4th(); - - /*TMR0_CNT = 0x0000;*/ - /*TMR0_SR = 0;*/ - /*TMR0_RC = 1059;*/ - /*TMR0_CR = 0x003C;*/ - - /* 8e6 / (16*19200) - 1 = 25.0416 */ - /* 8e6 / (16*2400) - 1 = 207.33 */ - /* 25e6 / (16*2400) - 1 = 207.33 */ - UART0_BCR = BCR(25000000L, 2400L); - UART0_CR = UARTEn; - - dint(); - putchar('!'); - - while (1) { - uint8_t c; - c = getchar(); - if (c == '`') break; - putchar(c); - } - - putchar('t'); - putchar('e'); - putchar('s'); - putchar('t'); - putchar('i'); - putchar('n'); - putchar('g'); - puts("This is a test of the UART serial printing\r\nit really does work ...\r\n"); - - processLoop(); - - return 0; + PAPER = 0x0030; + PAOUT = 0x0000; + PAOEN = 0x0010; // set data direction registers + + init_msp4th(); + + /*TMR0_CNT = 0x0000;*/ + /*TMR0_SR = 0;*/ + /*TMR0_RC = 1059;*/ + /*TMR0_CR = 0x003C;*/ + + /* 8e6 / (16*19200) - 1 = 25.0416 */ + /* 8e6 / (16*2400) - 1 = 207.33 */ + /* 25e6 / (16*2400) - 1 = 207.33 */ + UART0_BCR = BCR(25000000L, 2400L); + UART0_CR = UARTEn; + + dint(); + putchar('!'); + + char c; + while (1) { + c = getchar(); + if (c == '`') + break; + putchar(c); + } + + putchar('t'); + putchar('e'); + putchar('s'); + putchar('t'); + putchar('i'); + putchar('n'); + putchar('g'); + puts("This is a test of the UART serial printing\r\nit really does work ...\r\n"); + + processLoop(); + + return 0; } diff --git a/msp4th/mkfile b/msp4th/mkfile index bb54344..c4722b0 100644 --- a/msp4th/mkfile +++ b/msp4th/mkfile @@ -8,6 +8,8 @@ # $(TARGET).elf $(TARGET).hex and $(TARGET).txt and $(TARGET).map are all generated. # The TXT file is used for BSL loading, the ELF can be used for JTAG use # +SHELL = /bin/bash + TARGET = main #MCU = msp430f5529 MCU = msp2 @@ -20,8 +22,9 @@ INCLUDES = -I. # Add or subtract whatever MSPGCC flags you want. There are plenty more ####################################################################################### CFLAGS = -mmcu=$(MCU) -g -Os -Wall -Wunused $(INCLUDES) -ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs -LDFLAGS = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map +#ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp -Wa,-gstabs +ASFLAGS = -mmcu=$(MCU) -Os -Wall -Wunused +LDFLAGS = -mmcu=$(MCU) -Wl,-Map=$(TARGET).map -T ldscript_ns430 ######################################################################################## CC = msp430-gcc LD = msp430-ld @@ -41,42 +44,58 @@ MV = mv ######################################################################################## # the file which will include dependencies DEPEND = $(SOURCES:.c=.d) + # all the object files OBJECTS = $(SOURCES:.c=.o) -all: $(TARGET).elf $(TARGET).hex $(TARGET).txt + +# all asm files +ASSEMBLYS = $(SOURCES:.c=.lst) + +#all: $(TARGET).elf $(TARGET).hex $(TARGET).txt +all: $(TARGET).elf $(TARGET).hex $(ASSEMBLYS) + $(TARGET).elf: $(OBJECTS) - echo "Linking $@" + @echo "Linking $@" $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@ - echo - echo ">>>> Size of Firmware <<<<" + @echo + @echo ">>>> Size of Firmware <<<<" $(SIZE) $(TARGET).elf - echo + @echo + %.hex: %.elf $(OBJCOPY) -O ihex $< $@ + %.txt: %.hex $(MAKETXT) -O $@ -TITXT $< -I unix2dos $(TARGET).txt # The above line is required for the DOS based TI BSL tool to be able to read the txt file generated from linux/unix systems. +# %.o: %.c - echo "Compiling $<" + @echo "Compiling $<" $(CC) -c $(CFLAGS) -o $@ $< + # rule for making assembler source listing, to see the code %.lst: %.c - $(CC) -c $(ASFLAGS) -Wa,-anlhd $< > $@ + @#$(CC) -S $(ASFLAGS) -Wa,-anlhd -o $@ $< + $(CC) -S $(ASFLAGS) -o $@ $< + # include the dependencies unless we're going to clean, then forget about them. ifneq ($(MAKECMDGOALS), clean) -include $(DEPEND) endif + # dependencies file # includes also considered, since some of these are our own # (otherwise use -MM instead of -M) %.d: %.c - echo "Generating dependencies $@ from $<" + @echo "Generating dependencies $@ from $<" $(CC) -M ${CFLAGS} $< >$@ -.SILENT: + +#.SILENT: .PHONY: clean clean: - -$(RM) $(OBJECTS) - -$(RM) $(TARGET).{,elf,hex,txt,map} - -$(RM) $(SOURCES:.c=.lst) - -$(RM) $(DEPEND) + $(RM) $(OBJECTS) + $(RM) $(TARGET).{elf,hex,txt,map} + $(RM) $(SOURCES:.c=.lst) + $(RM) $(DEPEND) + diff --git a/msp4th/msp4th.c b/msp4th/msp4th.c index 788d401..685d394 100644 --- a/msp4th/msp4th.c +++ b/msp4th/msp4th.c @@ -29,7 +29,7 @@ int16_t popMathStack(void); void pushMathStack(int16_t n); int16_t popAddrStack(void); void pushAddrStack(int16_t n); -int16_t lookupToken(uint8_t *x,uint8_t *l); +int16_t lookupToken(char *x, char *l); void luFunc(void); void numFunc(void); void ifFunc(uint8_t x); @@ -296,12 +296,12 @@ const int16_t progBi[] = { // address actually start at 10000 int16_t progCounter; -uint8_t lineBuffer[128]; /* input line buffer */ +char lineBuffer[128]; /* input line buffer */ uint16_t lineBufferPtr; /* input line buffer pointer */ // uint8_t xit; /* set to 1 to kill program */ -uint8_t wordBuffer[32]; // just get a word +char wordBuffer[32]; // just get a word uint8_t getKeyB(){ @@ -418,7 +418,7 @@ void pushAddrStack(int16_t n){ addrStack[addrStackPtr] = n; } -int16_t lookupToken(uint8_t *x,uint8_t *l){ // looking for x in l +int16_t lookupToken(char *x, char *l){ // looking for x in l int16_t i,j,k,n; j = 0; k = 0; @@ -466,7 +466,7 @@ int16_t lookupToken(uint8_t *x,uint8_t *l){ // looking for x in l void luFunc(){ int16_t i; - i = lookupToken(wordBuffer,(uint8_t *)cmdListBi); + i = lookupToken(wordBuffer, (char *)cmdListBi); if(i){ i += 20000; @@ -474,13 +474,13 @@ void luFunc(){ pushMathStack(1); } else { // need to test internal interp commands - i = lookupToken(wordBuffer,(uint8_t *)cmdListBi2); + i = lookupToken(wordBuffer, (char *)cmdListBi2); if(i){ i += 10000; pushMathStack(i); pushMathStack(1); } else { - i = lookupToken(wordBuffer,cmdList); + i = lookupToken(wordBuffer, cmdList); if(i){ pushMathStack(i); pushMathStack(1); @@ -493,7 +493,7 @@ void luFunc(){ void numFunc(){ // the word to test is in wordBuffer int16_t i,j,n; - puts((const uint8_t *)"in numFunc()\r\n"); + puts("in numFunc()\r\n"); puts(wordBuffer); // first check for neg sign i = 0; @@ -666,9 +666,9 @@ void execFunc(){ void execN(int16_t n){ int16_t i,j,k,m; int32_t x,y,z; - puts((const uint8_t *)"execN: "); + puts("execN: "); printNumber(n); - puts((const uint8_t *)"\r\n"); + puts("\r\n"); switch(n){ case 1: // xit = 1; @@ -752,8 +752,8 @@ void execN(int16_t n){ break; case 16: // keyt - // return a 1 if keys are in ring buffer - i = (inputRingPtrXin - inputRingPtrXout) & 0x0F; // logical result assigned to i + // return a 1 if keys are in ring buffer + //i = (inputRingPtrXin - inputRingPtrXout) & 0x0F; // logical result assigned to i i = 0; pushMathStack(i); break; @@ -761,7 +761,7 @@ void execN(int16_t n){ case 17: // allot prog[progPtr++] = popMathStack(); if(progPtr >= PROG_SPACE){ - puts((uint8_t *)"prog mem"); + puts("prog mem"); } break; @@ -823,7 +823,7 @@ void execN(int16_t n){ case 30: // num - puts((const uint8_t *)"in case 30\r\n"); + puts("in case 30\r\n"); numFunc(); break; @@ -999,21 +999,26 @@ void execN(int16_t n){ break; case 60: // fec + /* printHexWord(fecShadow[2]); putchar(' '); printHexWord(fecShadow[1]); putchar(' '); printHexWord(fecShadow[0]); + */ break; case 61: // fecset + /* fecShadow[0] = popMathStack(); // lsb fecShadow[1] = popMathStack(); fecShadow[2] = popMathStack(); //msb + */ /*sendToFEC(fecShadow);*/ break; case 62: // fecbset + /* i = popMathStack(); if(i < 48 && i >= 0){ j = i >> 4; // find the byte @@ -1021,10 +1026,12 @@ void execN(int16_t n){ i = 1 << i; // get the bit location fecShadow[j] |= i; } + */ /*sendToFEC(fecShadow);*/ break; case 63: // fecbclr + /* i = popMathStack(); if(i < 48 && i >= 0){ j = i >> 4; // find the byte @@ -1032,37 +1039,40 @@ void execN(int16_t n){ i = 1 << i; // get the bit location fecShadow[j] &= ~i; } + */ break; default: - puts((uint8_t *)"opcode "); + puts("opcode "); break; } } void init_msp4th(void) { -// xit = 0; - addrStackPtr = ADDR_STACK_SIZE; // this is one past the end !!!! as it should be - progCounter = 10000; - progPtr = 1; // this will be the first opcode - i=0; - cmdListPtr = 0; - cmdList[0] = 0; - progOpsPtr = 1; // just skip location zero .... it makes it easy for us - - dirMemory = (void *) 0; // its an array starting at zero + uint16_t i; - lineBufferPtr = 0; - for (i=0; i < 128; i++) { - lineBuffer[i] = 0; - } +// xit = 0; + addrStackPtr = ADDR_STACK_SIZE; // this is one past the end !!!! as it should be + progCounter = 10000; + progPtr = 1; // this will be the first opcode + i=0; + cmdListPtr = 0; + cmdList[0] = 0; + progOpsPtr = 1; // just skip location zero .... it makes it easy for us + + dirMemory = (void *) 0; // its an array starting at zero + + lineBufferPtr = 0; + for (i=0; i < 128; i++) { + lineBuffer[i] = 0; + } - for (i=0; i < 32; i++) { - wordBuffer[i] = 0; - } + for (i=0; i < 32; i++) { + wordBuffer[i] = 0; + } - getLine(); + getLine(); } @@ -1070,7 +1080,7 @@ void processLoop(){ // this processes the forth opcodes. int16_t opcode; while(1){ - puts((const uint8_t *)"processLoop()\r\n"); + puts("processLoop()\r\n"); if(progCounter > 9999){ opcode = progBi[progCounter - 10000]; } else { -- 2.25.1