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;
}
# $(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
# 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
########################################################################################
# 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)
+
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);
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(){
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;
void luFunc(){
int16_t i;
- i = lookupToken(wordBuffer,(uint8_t *)cmdListBi);
+ i = lookupToken(wordBuffer, (char *)cmdListBi);
if(i){
i += 20000;
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);
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;
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;
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;
case 17: // allot
prog[progPtr++] = popMathStack();
if(progPtr >= PROG_SPACE){
- puts((uint8_t *)"prog mem");
+ puts("prog mem");
}
break;
case 30: // num
- puts((const uint8_t *)"in case 30\r\n");
+ puts("in case 30\r\n");
numFunc();
break;
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
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
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();
}
int16_t opcode;
while(1){
- puts((const uint8_t *)"processLoop()\r\n");
+ puts("processLoop()\r\n");
if(progCounter > 9999){
opcode = progBi[progCounter - 10000];
} else {