Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by monsonite

  1. SIMPL = Serial Interpreted Minimal Programming Language Hi, It's been about a year since I talked about SIMPL - a tiny language that allows you basic control of a microcontroller using serial commands. In the 6 months I have coded it up in MSP430 assembly language to make it super compact - and fast - with high level commands taking about 1uS to execute on the virtual machine interpreter. SIMPL is based on a jump table - so for any single, printable ascii character, the jump table will act on it and execute whatever function you choose to write. This technique gives amazing flexibility, and for under 1K of code it can offer a very powerful user interface to your latest MSP430 project. One example is using the jump table to interpret commands from a text file to control a CNC mill or drill - or even a 3D printer. The core routines can be applied to any MSP430 - you just have to change the initialisation routines to suit the DCO, GPIO and UART of the specific microcontroller Just this week, I have got the looping to work, so you can now do things like send square waves to port pins for flashing LEDs and creating musical tones. With the standard Launchpad (MSP430GR2553) clocked at 16MHz you can send a 1uS pulse to a port pin - just by typing hl (shorthand for high, low) at the serial terminal. SIMPL is coded up in just 872 bytes of program memory - and can handle up to 96 separate commands. Commands can be sent to the device from a text file - using teraterm or similar - or just typed manually at the keyboard. I have put the latest code (some recent changes) on this github gist https://gist.github.com/monsonite/6483a32404c1c53cd8027dd6f9dcea6e This is a work in progress - and there are still a few bugs - but the basics seem to work OK. regards Ken Here's some more info about the various routines that make up the kernel textRead 33 Instructions 90 bytes Receive characters from the serial uart and place them into a buffer in RAM. Two modes of operation are possible, immediate mode, where the characters are executed as instructions directly after a carriage return line feed is received, and compile mode, where the character sequences are preceded by a colon and stored in pre-calculated command buffers in RAM. number 16 instructions 42 bytes Number interprets sequences of consecutive digits as a 16-bit integer number and places the value in the register that is the top entry of the stack. next 5 instructions 12 bytes Next is the routine that all commands return the program flow back to once they have executed. It fetches the next character instruction from the RAM buffer and through a jump table technique passes program control to the code body that performs the task associated with that instruction. The jump table is used to direct the character to the areas of code that will treat them correctly - for example on encountering a numerical digit, program control is passed to the number routine, whilst for upper case alphabetical characters, program control is passed to a routine that handles these separately. jump_table 96 instructions 192 bytes Primitives 72 instructions 166 bytes SIMPL uses a collection of 32 instruction primitives from which other instructions can be synthesised. The code body of these primitives is some 100 instructions or so. Upper (called alpha in V1) 10 instructions 26 bytes Upper handles the capital letters - as these are user commands, and the user is able to write and store in RAM certain functionality based on these characters. When a capital letter is encountered in the instruction buffer, Upper directs control to the correct command buffer. Lower 86 bytes Lower is an area of program that interprets the lower case characters and provides a higher level of program complexity than is achievable form the primitives alone. printnum 30 instructions 106 bytes This takes a 16 bit integer number from the stack and prints a string of ascii digit characters to the terminal. Uart Routines 13 instructions 41 bytes Low level communication with the uart is by way of the get_c and put_c routines Initialisation 19 instructions 90 bytes Here the hardware such as the oscillator, GPIO and uart are initialised for correct operation. This is code specific to whichever microcontroller has been chosen Interpreter 4 instructions 16 bytes This is the main routine that runs the SIMPL interpreter combining textRead, next, number and Upper. Here's the code - as it stands. Code window has mess up the formatting - but it should still cut and paste ;------------------------------------------------------------------------------- ; SIMPL - a very small Forth Inspired Extensible Language ; Implementing the Initialisation, TextTead, TextEval and UART routines in MSP430 assembly language ; ; A Forth-Like Language in under 1024 bytes ; Ken Boak May 22nd/23rd 2017 ; Loops, I/O, Strings and Delays added ; This version 872 bytes ; Instructions take about 1uS cycle time - so about 1/16th of clockspeed ;------------------------------------------------------------------------------- .cdecls C,LIST,"msp430.h" ; Include device header file ;------------------------------------------------------------------------------- .def RESET ; Export program entry-point to ; make it known to linker. ;------------------------------------------------------------------------------- ; Variables ;------------------------------------------------------------------------------- .sect "vars" .bss parray, 256 .bss x, 2 .bss name, 2 ;------------------------------------------------------------------------------- ; Using the register model of CH Ting's Direct Thread Model of MSP430 eForth ; CPU registers ; Register Usage ; R0 MSP430 PC Program Counter ; R1 MSP430 SP Stack Pointer ; R2 MSP430 SR Status Register tos .equ R4 stack .equ R5 ip .equ R6 temp0 .equ R7 ; loop start temp1 .equ R8 ; loop counter k temp2 .equ R9 ; millisecond delay temp3 .equ R10 ; microsecond delay temp4 .equ R11 instr .equ R12 temp5 .equ R13 temp6 .equ R14 ; temp7 .equ R15 ; Return from alpha next IP ;------------------------------------------------------------------------------- ; Macros pops .macro ;DROP mov.w @stack +, tos .endm pushs .macro ;DUP decd.w stack mov.w tos, 0(stack) .endm; ; Constants $NEXT .macro jmp next ; mov @ip+, pc ; fetch code address into PC .endm $NEST .macro .align 2 call #DOLST ; fetch code address into PC, W = PFA .endm $CONST .macro .align 2 call #DOCON ; fetch code address into PC, W = PFA .endm ;------------------------------------------------------------------------------ ;; Assembler constants COMPO .equ 040H ;lexicon compile only bit IMEDD .equ 080H ;lexicon immediate bit MASKK .equ 07F1FH ;lexicon bit mask CELLL .equ 2 ;size of a cell BASEE .equ 10 ;default radix VOCSS .equ 8 ;depth of vocabulary stack BKSPP .equ 8 ;backspace LF .equ 10 ;line feed CRR .equ 13 ;carriage return ERR .equ 27 ;error escape TIC .equ 39 ;tick CALLL .equ 012B0H ;NOP CALL opcodes UPP .equ 200H DPP .equ 220H SPP .equ 378H ;data stack TIBB .equ 380H ;terminal input buffer RPP .equ 3F8H ;return stacl CODEE .equ 0C000H ;code dictionary COLDD .equ 0FFFEH ;cold start vector EM .equ 0FFFFH ;top of memory ;------------------------------------------------------------------------------- .text ; Assemble into program memory. .retain ; Override ELF conditional linking ; and retain current section. .retainrefs ; And retain any sections that have ; references to current section. ;------------------------------------------------------------------------------- ; This implements the SIMPL interpreter is MSP430 assembly Language ;------------------------------------------------------------------------------- ; textRead ; ------------------------------------------------------------------------------ ; Get a character from the UART and store it in the input buffer starting at 0x0200 ; Register Usage ; The input buffer - start is at 0x0200, which is pointed to by R14 ; R11 is a counter to ensure that we don't exceed 64 characters in input buffer ; R12 receives the character from the uart_get_c routine and puts in the buffer, pointed to by R14 ; R14 is the current character position in the input buffer ; 33 instructions textRead: MOV.W #0x0200,R14 ; R14 = start of input buffer in RAM CLR.B R11 ; i = 0 getChar: CALL #uart_getc ; char ch = uart_getc() CMP.B #0x000d,R12 ; is it carriage return? 0d JEQ textEnd CMP.B #0x000a,R12 ; Is it newline? 0a JEQ textEnd CMP.B #0x0020,R12 ; if (ch >= ' ' && ch <= '~') JLO nonValid CMP.B #0x007f,R12 JHS nonValid CMP.B #0x003A,R12 ; is it colon? 3A JNE notColon colon: ; If the input character is a colon CALL #uart_getc ; get the next character - which is the NAME MOV.B R12,R13 ; move the 1st character after the colon to "name" variable in R13 times_32: SUB.B #0x0041,R13 ; Calculate the destination address - subtract 65 to remove offset of letter A ADD.W R13,R13 ; Double R13 ; multiply by 2 ADD.W R13,R13 ; Double R13 ; multiply by 4 ADD.W R13,R13 ; Double R13 ; multiply by 8 ADD.W R13,R13 ; Double R13 ; multiply by 16 ADD.W R13,R13 ; Double R13 ; multiply by 32 ADD.W R13,R14 ; Add (32*R13) to the index pointer R14 ADD.W #0x020,R14 ; Add to array pointer 0x0220 MOV.B R12,0x0000(R14) ; Store character at RAM buffer indexed by R14 ; R14 now contains the destination address JMP incPointer notColon: INC.W R14 ; Increment buffer pointer MOV.B R12,0xffff(R14) ; Store character at RAM buffer indexed by R14 incPointer: INC.B R11 ; Increment the input buffer pointer i++; nonValid: CMP.B #0x003f,R11 ; If input pointer <64 loop back to start JLO getChar ; loop back and get next character textEnd: mov.b #0x00,0x0000(R14) ; Put a null terminating (0x80) zero on the end of the buffer ; MOV.B R11,0x0000(R14) ; Put a null terminating (0x80) zero on the end of the buffer RET ;------------------------------------------------------------------------------------------------------------------- ; We now come onto the textEval - where based on the value of the character we perform some action routine ; But first we need to determine whether the characers form part of a number - and these must be decoded separately ; and put on the stack ;------------------------------------------------------------------------------------------------------------------- ; Register Usage ; ip - instruction pointer to the current character in the input buffer ; R12 is the accumulator for the number - then stored in location #0x380 ; R13 Temporary - use in x10 multipication ; R14 ; 16 Instructions number: SUB.W #0x0030,R12 ; subtract 0x30 to get a decimal number number1: CMP.B #0x0030,0x0000(ip) ; >= '0' Is the next digit a number JLO endNumber ; break CMP.B #0x003a,0x0000(ip) ; <= '9' JHS endNumber ; break times_10: ; This multipies R12 by 10 ADDC.W R12,R12 ; R12 = 2 * R12 MOV.W R12,R13 ; R13 = 2 * R12 ADDC.W R12,R12 ; R12 = 4 * R12 ADDC.W R12,R12 ; R12 = 8 x R12 ADDC.W R13,R12 ; R12 = 10 x R12 MOV.B @ip+,R14 ; Increment the instruction pointer fetching the next digit SUB.W #0x0030,R14 ADD.W R14, R12 ; Add in the next digit JMP number1 ; process the next digit endNumber: MOV.W R12, tos ; Put in tos - the top of stack JMP next ; process the next character ; Character is either a primitive or an alpha - so form CALL address ; Restore R14 to start of RAM buffer ; Get the current character location ; If it's a primitive between 0x20 and 0x3F - point to a look-up table and fetch it's code segment address ; If its an Alpha, or character >0x40 calculate it's code address from (char - 65)x32 ; Character is in R13 so calculate the destination address ; ------------------------------------------------------------------------------------------------------------------- ; next fetches the next ascii character instruction from memory, decodes it into a jump address and executes the code ; found at that code address ; Each executed word jumps back to next ; Numbers are treated differenty - they are enummerated and put onto the stack by the number routine ; Now we need to decode the instructions using a jump table ; Jump table uses 2 bytes per instruction - so 2 x 96 = 192 bytes next: MOV.B @ip+,R12 ; Get the next character from the instruction memory MOV.W R12,R13 ; Copy into R13 - as needed to decode Jump Address SUB.w #0x0020,R13 ; subtract 32 to remove offset of space ADD.w R13,R13 ; double it for word address add.w R13,pc ; jump to table entry tabstart: jmp space ; SP jmp store ; ! jmp dup ; " jmp lit ; # jmp swap ; $ jmp over ; % jmp and ; & jmp drop ; ' jmp left_par ; ( jmp right_par ; ) jmp mult ; * jmp add ; + jmp push ; , jmp sub ; - jmp pop ; . jmp div ; / jmp number ; 0 jmp number ; 1 jmp number ; 2 jmp number ; 3 jmp number ; 4 jmp number ; 5 jmp number ; 6 jmp number ; 7 jmp number ; 8 jmp number ; 9 jmp colon ; : jmp semi ; ; jmp less ; < jmp equal ; = jmp greater ; > jmp query ; ? jmp fetch ; @ jmp alpha ; A jmp alpha ; B jmp alpha ; C jmp alpha ; D jmp alpha ; E jmp alpha ; F jmp alpha ; G jmp alpha ; H jmp alpha ; I jmp alpha ; J jmp alpha ; K jmp alpha ; L jmp alpha ; M jmp alpha ; N jmp alpha ; O jmp alpha ; P jmp alpha ; Q jmp alpha ; R jmp alpha ; S jmp alpha ; T jmp alpha ; U jmp alpha ; V jmp alpha ; W jmp alpha ; X jmp alpha ; Y jmp alpha ; Z jmp square_left ; [ jmp f_slash ; \ ; jmp square_right ; ] jmp xor ; ^ jmp underscore ; _ jmp tick ; ` jmp lower_a ; a jmp lower_b ; b jmp lower_c ; c jmp lower_d ; d jmp lower_e ; e jmp lower_f ; f jmp lower_g ; g jmp lower_h ; h jmp lower_i ; i jmp lower_j ; j jmp lower_k ; k jmp lower_l ; l jmp lower_m ; m jmp lower_n ; n jmp lower_o ; o jmp lower_p ; p jmp lower_q ; q jmp lower_r ; r jmp lower_s ; s jmp lower_t ; t jmp lower_u ; u jmp lower_v ; v jmp lower_w ; w jmp lower_x ; x jmp lower_y ; y jmp lower_z ; z jmp curly_left ; { jmp or ; | jmp curly_right ; } jmp inv ; ~ jmp delete ; del jmp textEval_end ; 0x80 is used as null terminator ;----------------------------------------------------------------------------------------- ; Handle the alpha and lower case chars alpha: SUB.B #0x0041,R12 ; subtract 65 to remove offset of letter A from original character MOV.W R12,R13 ; get it into R13 for multiplying ADD.W R13,R13 ; Double R13 ; multiply by 2 ADD.W R13,R13 ; Double R13 ; multiply by 4 ADD.W R13,R13 ; Double R13 ; multiply by 8 ADD.W R13,R13 ; Double R13 ; multiply by 16 ADD.W R13,R13 ; Double R13 ; multiply by 32 ADD.W #0x220,R13 ; Add (32*R13) to the index pointer R14 MOV.W ip,R15 ; Save the current ip on the return stack R15 ; R13 now contains the jump address for the alpha code MOV.W R13,ip ; instruction pointer JMP next ; process the next character ;----------------------------------------------------------------------------------------- ; Handle the primitive instructions space: pushs ; Move a 2nd number onto the stack $NEXT store: mov.w @stack +, 0(tos) pops $NEXT dup: pushs $NEXT lit: $NEXT swap: mov.w tos, temp0 mov.w @stack, tos mov.w temp0,0( stack) $NEXT over: mov.w tos, temp0 mov.w @stack, tos mov.w temp0,0( stack) $NEXT and: and @stack +, tos $NEXT drop: pops $NEXT left_par: ; code enters here on getting a left parenthesis MOV.W tos,R8 ; save tos to R8 (R8 is the loop counter k) MOV.W ip,R7 ; loop-start = ip the current instruction pointer at start of loop JMP next ; get the next character and execute it right_par: ; code enters here if instruction it's a right parenthesis ; TST.W R8 ; is loop counter zero ; JEQ next ; terminate loop DEC.W R8 ; decrement loop counter R8 JEQ next ; terminate loop MOV.W R7,ip ; set instruction pointer to the start of the loop JMP next ; go around loop again until loop counter = 0 mult: $NEXT add: add @stack +, tos $NEXT push: $NEXT sub: sub @stack +, tos ; jmp NEGAT NEGAT: inv tos inc tos $NEXT pop: jmp printNum ; go to decimal number print $NEXT div: $NEXT semi: ; On encountering a semicolon return program control to the next character in the input buffer MOV.W R15,ip ; restore the ip $NEXT query: $NEXT fetch: mov.w @tos, tos $NEXT square_right: f_slash: square_left: curly_right: curly_left: underscore: ; Print the enclosed text print_start: MOV.B @ip+,R12 ; Get the next character from the instruction memory CMP.B #0x005f,R12 ; is it an underscore jeq print_end CALL #uart_putc ; send it to uart jmp print_start print_end call #crlf ; line feed at end of text string $NEXT tick: ; tick allows access to the loop counter MOV.W R8,tos $NEXT delete: $NEXT or: bis @stack +, tos $NEXT xor: xor @stack +, tos $NEXT inv: inv tos $NEXT less: cmp @stack +, tos jz FALSE jge TRUE jmp FALSE equal: xor @stack +, tos jnz FALSE jmp TRUE greater: cmp @stack +, tos jge FALSE jmp TRUE FALSE: clr tos $NEXT TRUE: mov #0x01, tos $NEXT ;------------------------------------------------------------------------------------------------ ;lower case routines lower_a: $NEXT lower_b: $NEXT lower_c: $NEXT lower_d: $NEXT lower_e: $NEXT lower_f: $NEXT lower_g: $NEXT lower_h: MOV.B #0x0001,&P1OUT ; P1OUT = BIT0 LED1 on $NEXT lower_i: $NEXT lower_j: $NEXT lower_k: ; k allows access to the loop counter variable stored in R8 MOV.W R8,tos $NEXT lower_l: MOV.B #0x0000,&P1OUT ; P1OUT = BIT0 LED1 off $NEXT lower_m: ; millisecond delay MOV.W tos,R10 mS_loop: mov.w #5232,R9 ; 5232 gives 1mS at 16MHz uS3_loop: DEC.W R9 JNE uS3_loop DEC.W R10 JNE mS_loop $NEXT lower_n: $NEXT lower_o: $NEXT lower_p: JMP printNum $NEXT lower_q: $NEXT lower_r: $NEXT lower_s: $NEXT lower_t: $NEXT lower_u: ; 3 microsecond deelay MOV.W tos,R10 uS_loop: DEC.W R10 JNE uS_loop $NEXT lower_v: $NEXT lower_w: $NEXT lower_x: $NEXT lower_y: $NEXT lower_z: $NEXT ;------------------------------------------------------------------------------------------------ ; User Routines ;------------------------------------------------------------------------------------------------- printNum: ; Take the 16 bit value in R4 stack register and print to terminal as an integer ; do by repeated subtraction of powers of 10 ; Uses R10,11,12,13 ;------------------------------------------------------------------------------------------------- MOV.W #10000,R10 ; R10 used as the decimation register ; CLR.W R12 ; use R12 as a counter CLR.W R11 ; Use R11 as scratch CLR.W R13 MOV.W tos,R12 ; copy the top of stack into R12 CLRC ; clear the carry sub10K: SUB.W R10,R12 JLO end10K add10K: ADD.B #1,R11 ; increments the digit count add_zero: ADD.W R10,R13 ; R13 increases by the decimal value each time JMP sub10K end10K: ADD.B #0x30,R11 ; make it a number MOV.W R11,R12 CALL #uart_putc ; output character SUB.W R13,tos ; Decrement the stack count by n x 10 CLR.W R11 ; Use R11 as scratch CLR.W R13 MOV.W tos,R12 decimate: CMP.W #10000,R10 JEQ use1K CMP.W #1000,R10 JEQ use100 CMP.W #100,R10 JEQ use10 CMP.W #10,R10 JEQ use1 newline: MOV.W #0x0A, R12 CALL #uart_putc ; output CR MOV.W #0x0D, R12 CALL #uart_putc ; output LF JMP next use1K: MOV.W #1000,R10 JMP sub10K use100: MOV.W #100,R10 JMP sub10K use10: MOV.W #10,R10 JMP sub10K use1: MOV.W #1,R10 JMP sub10K ;------------------------------------------------------------------------------------------------- ;------------------------------------------------------------------------------------------------------------------- ; Uses R12 to send receive chars via the UART at 115200 baud. uart_getc: BIT.B #1,&IFG2 ; while (!(IFG2&UCA0RXIFG)) // USCI_A0 RX buffer ready? JEQ (uart_getc) MOV.B &UCA0RXBUF,R12 ; return UCA0RXBUF; RET uart_putc: BIT.B #2,&IFG2 ; while (!(IFG2&UCA0TXIFG)) // USCI_A0 TX buffer ready? JEQ (uart_putc) MOV.B R12,&UCA0TXBUF ; UCA0TXBUF = c; // TX RET crlf: MOV.W #0x0A, R12 CALL #uart_putc ; output CR MOV.W #0x0D, R12 CALL #uart_putc ; output LF RET ;------------------------------------------------------------------------------- ; Main loop here ;------------------------------------------------------------------------------- main: ;------------------------------------------------------------------------------- RESET: ; mov.w #03E0h,SP ; Initialize stackpointer mov #RPP, SP ; set up stack mov #SPP, stack clr tos StopWDT: mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer WDTCTL = WDTPW + WDTHOLD; Stop WDT OSC_GPIO_init: ; Run the CPU at full 16MHz with 11500baud UART MOV.B &CALBC1_16MHZ,&BCSCTL1 ;BCSCTL1 = CALBC1_16MHZ; Set DCO MOV.B &CALDCO_16MHZ,&DCOCTL ;DCOCTL = CALDCO_16MHZ; SetupP1: bis.b #041h,&P1DIR ;P1.0 P1.6 output as P1.0 and P1.6 are the red+green LEDs MOV.B #0x0000,&P1OUT ;P1OUT = BIT0 + BIT6; // All LEDs off uart_init: MOV.B #0x0006,&P1SEL ;Initialise the UART for 115200 baud MOV.B #0x0006,&P1SEL2 ;P1SEL2 = RXD + TXD; BIS.B #0x0080,&UCA0CTL1 ;UCA0CTL1 |= UCSSEL_2// SMCLK MOV.B #0x008A,&UCA0BR0 ;UCA0BR0 = 138 // 16MHz 115200 CLR.B &UCA0BR1 ;UCA0BR1 = 0 // 16MHz 115200 MOV.B #2,&UCA0MCTL ;UCA0MCTL = UCBRS0 // Modulation UCBRSx = 1 BIC.B #1,&UCA0CTL1 ;UCA0CTL1 &= ~UCSWRST Initialize USCI state machine MOV.W #0x4F, R12 CALL #uart_putc ; output "O" MOV.W #0x4B, R12 CALL #uart_putc ; output "K" ; Print OK ;------------------------------------------------------------------------------- interpreter: call #textRead MOV.W #0x0200,ip ; set ip (instruction pointer) - to start of input buffer in RAM at address 0x0200 jmp next ; get the next instruction textEval_end: jmp interpreter ; loop around ; Stack Pointer definition ;------------------------------------------------------------------------------- .global __STACK_END .sect .stack ;------------------------------------------------------------------------------- ; Interrupt Vectors ;------------------------------------------------------------------------------- .sect ".reset" ; MSP430 RESET Vector .short RESET .end
  2. Hi All, Would there be sufficient interest in some of the new FRAM parts to warrant an update of Energia to support these? The $16 MSP430FR5994 LaunchPad is remarkable value, and an ideal platform for datalogger/low power sensor applications with 256Kbytes of FRAM, a microSD card, and 68 lines of I/O. The MSP430FR2433 is also a neat little part, and if you need 4 x 24bit ADCs for instrumentation or energy monitoring the MSP430i2041 is one of the cheapest solutions for independent 24 bit ADCs around. I would be interested to know if there is a plan for Energia to support these recently released new parts? Ken London
  3. Hi All, It's about a month since my last update, and following on from the breadboard prototype, the project has been gathering momentum. After an initial review of the various MSP430 devices it was decided to opt for a generic smart analogue sensor design, capable of driving an OLED display. I selected to use the MSP430i2041 ( which was chosen for it's 4 x SD24 ADCs) in order to make precision sensor measurements. It uses a low noise differential input instrumentation amplifier. Typically it can be used for bridge sensors, current shunts, milliohm measurements, strain-gauges, PT100 and thermocouple temperature measurements etc, etc. The product is on a small board - just 42 x 53mm (1.65" x 2.1"), and has a forwards facing OLED display and 4 button user interface. As stated last month I am using the MSP430i2041 and 128K byte 23LC1024 SPI serial SRAM. I am using my SIMPLEX Forthlike language which now executes code out of external serial memory, or an be used to respond to serial commands (requests for ADC reading data etc) over a serial link. A super capacitor and LiPo battery are used to allow for non-volatile memory. As this has been designed as an evaluation, all of the 'i2041 mcu pins are available on 2 x 16 pin header strips - allowing it to be plugged into a breadboard, stripboard, or connected to a Launchpad with jumper wires, using just Rx, Tx, 3V3 and 0V. The Launchpad '4133 or '6989 are preferred as they provide a 6 digit LCD "meter" like display. USB to serial communications is handled using a CH340G USB-serial IC. There is an on board LiPo charger and boost regulator - allowing the board to run from a LiPo or - as little as a 1V dc supply. A Bluetooth Low Energy module allows data to be sent to smart phone or tablet. Just to let you know that the pcbs for the above project arrived today and I already have a couple of them built up. I will be posting some pictures up to this thread over the next couple of days. If the module is successful, I hope to be able to open source at least some of the design, for those who are interested. It would be great to have MSP430i20xx support on Energia - allowing this module to be simply programmed. Ken London
  4. noForth appears to be a very nice implementation - written by Dutch developers, Albert Nijhof & Willem Ouwerkerk It is a good implementation for the MSP430 - especially if you are working with G2 Launchpad , '5739 EXP or '5969 EXP. noForth also supports the following boards with noForth C or noForth V - which has support for the FRAM Documentation about the boards (.pdf) Lp, Mc, Du, Mv, Ex intel hex files (.a43) of actual noForth versions (160401) MSP430G2553 Launchpad 16kB FROM Lp noForth C noForth V noForth C- noForth V- MSP430G2553 Egel Kit 16kB FROM, Baud rate 38k4 Ek noForth C noForth V noForth C- noForth V- MSP430F149 Minim Core Board 61kB FROM Mc noforth C noforth V MSP430F149 Dupont board 61kB FROM Du noForth C noForth V MSP430F149 Mini-V3 board 61kB FROM Mv noForth C noForth V MSP-EXP430FR5739 Experimenter Board 16kB FRAM Ex noForth C noForth V MSP-EXP430FR5969 Experimenter Board 64kB FRAM, Baud rate 38k4 Ex noForth C noForth V . See this page for links to the above http://home.hccnet.nl/anij/nof/noforth.html For Linux users - the writers of noForth have produced the e4thcom "Forth Terminal" - which is an integrated solution to communications and file save/load for writing Forth source code. http://www.forth-ev.de/wiki/doku.php/en:projects:e4thcom There is definitely increasing interest in Forth for small embedded microcontrollers - especially the MSP430. Most of the implementations are free to download - and there is a good community around the German Forth group http://www.forth-ev.de/ If you don't speak German - then much of the group's content is in English - or you can very easily use Google Translate on their web pages, wiki etc. Ken
  5. One month later - and I have the MSP430i2041 running my Simplex code - reading a strain gauge loadcell and measuring force through the 24bit ADC. Here's the prototype on a breadboard. The MSP430i2041 is mounted on the "Schmartboard" carrier, and the 8 pin chip to the left is a 128K x 8 SRAM - Microchip 23LC1024 The MSP430i2041 has 4 separate 24bit SD-ADC channels with built in programmable gain amplifiers with differential inputs. Ideal for strain-gauge type sensors - with almost no external components needed for interfacing. You can have UART to PC and SPI and a couple of LEDs on Port 1, and still have all 8 bits of Port 2 for other purposes - such as a set of switches, character LCD etc. This is a really cheap way of getting a a "Smart" 24bit ADC - about $2 in volume. The second part of the project is the display controller - to drive a segment type LCD. This will use either MSP430FR4133 for segment LCD or MSP430FR6989 for full graphic LCD - both of which can be done using Launchpads to act as the target hardware. Here's the photo Next week the plan is to design a small pcb, in a Boosterpack format - that will allow the MSP430i2041 & SRAM to be added to a '4133 or '6989 Launchpad. This will make a more stable integrated unit, and having a quad 24 bit SD-ADC for a Launchpad - has to be useful??
  6. Over the last couple of days Matthias Koch has ported his Mecrisp MSP430 Forth 2.03 across to my MSP430FR2433 ChipStick design. I am now happy to report that the first testing happened earlier this evening - so now we have a good native assembly language Forth running on the ChipStick. There will be an update to my GitHub - in the next couple of days. Ken
  7. Hi All, I am aware of the limitations of the BSL, and the power of the Mass Erase function. I am suggesting that BSL is a convenient way of getting your initial code into the device - in my case an image of Forth or Simplex. Once this code is in place you have a device that runs an interpreted language, with it's own mechanism for programming code into the FRAM. Perhaps I should have made this clearer in my post. Ken
  8. I got interested in the BSL bootloader about 6 weeks ago whilst trying to find a programming solution for a product at my work. I have done a bit of research and written it up as a 2 part post on my blog: Part 1 http://sustburbia.blogspot.co.uk/2016/02/the-great-msp430-bootloader-swindle.html Part 2 http://sustburbia.blogspot.co.uk/2016/03/the-great-msp430-bootloader-swindle.html If you want to program an MSP430 but don't want to have to use a FET based device, then this could be what you are looking for. My programmer? Sure - that's it on the left hand end of my ChipStick board - costs about $1. Ken
  9. Thanks Rando I am trying to get some documentation together - that is more easily followed. Start off with Ward Cunningham's Txtzyme website - which explains the basics. It should be a fairly simple port to the 16Fxxxx https://github.com/WardCunningham/Txtzyme I just built on his foundations. His <100 line interpreter code is still at the heart of my implementation. My interest started 3 years ago - http://sustburbia.blogspot.co.uk/2013/05/simpl-simple-programming-language-based.html Ken BTW I now have it running on 4 different MSP430 chips (G2533, FR4133, FR2433, i2041) , and all the ARM Cortex M3, M4, M7 I work with . It's the first thing I try to implement on a new mcu - it's like having an old friend along for the ride.
  10. I have put the pictorial construction guide for ChipStick on my Blog. It gives an idea of how to assemble the pcb by hand - should you wish. However - these will be professionally built by pick and place machine in China later in the Summer, at a price that would be difficult to match by any means. http://sustburbia.blogspot.co.uk/2016/03/building-chipstick-construction-guide.html The EagleCAD files, Gerbers and a representative, (but not finalised) BOM is also available from my GitHub repository. You will be amazed how cheap components are, when sourced from China - literally cents. The whole BOM comes out at well under $4, of which 65% is the cost of the MSP430 and the Microchip SRAM. The latest 128K external RAM version of the SIMPLEX code for #ChipStick is now up on my GitHub SIMPLEX_2_MSP430FR2433_11.c https://github.com/monsonite/SIMPL It has developed primarily as test code to exercise the external RAM, and to prove that data can be moved to and from external RAM and that interpreted code can be run from there. It's buggy, it's quirky and it's in no way a finished product - but hey, I am a Hardware Engineer, who's slowly learning C and the MSP430 by doing this! Send me some feedback if you need more information. Ken
  11. An Update, I have now partially built up a batch of 14 ChipSticks, and completed 4. The remainder will be done during the week. Over the weekend I have written some more code to exercise the on board 128K byte RAM - and this appears to be working well. I can now execute my Simplex code out of the external SRAM. There will be an update to the code on my Github plus some more information geaned whilst building these up. It's not often you get an uninterrupted 4 day stretch to work intensively on a project like this. I can return to work tomorrow - knowing that most of what I aimed to achieve this weekend has been accomplished. The MSP430FR2433 device is still on a 12 week leadtime - so that puts us into nearly July before these are able to be manufactured in volume. Some beta samples may be available in due course. Ken
  12. In this post I reveal the applications of the new product I have been working on this last month. ChipStick is a tiny, low cost ($10) 16 bit microcomputer based on the MSP430FR2433 attached to a PC via a USB cable. It comes with up to 256K bytes of non-volatile memory - uniquely using ferro-electric memory. It has up to 16 accessible GPIO lines - which include a mix of SPI, I2C, UART, Timer and ADC channels. ChipStick may be plugged into a breadboard or stripboard and act as an intelligent programmable controller interfacing with other circuitry. ChipStick can also act as a Digital Debug Tool (DDT), with jumper wires attached, - used to debug/develop low voltage (3V3) target hardware. This is not for "MSP430" debugging - more a general purpose tool for exercising digital hardware, ICs etc In each case, the extendable Scripting Language SIMPLEX may be tailored to the exact requirements of the user's application. ChipStick is based on non-volatile ferroelectric technology. This means that your applications and any recorded data remain in memory even after power down. ChipStick may be extended in hardware to meet the requirements of the application - this is planned through both a series of larger expansion boards (based on the low cost 50x50mm format) and stackable micro-modules that match the DIL 20 socket format. In this respect, a high resolution 4 channel 24-bit ADC micro-module is under development which additionally provides 8 extra GPIO lines for external applications This 24-bit module opens up the ability to interface to high resolution sensors such as loadcells, strain-gauges, precision temperature sensors, energy monitors and other applications where 10 bits of ADC resolution is just not enough. Other modules in planning are a high speed flash converter for digital oscilloscope projects and high speed capture/replay memory for logic analysers, arbitrary waveform generators and VGA video generation. Applications With these primary applications in mind, ChipStick has been designed to be as versatile as possible - within the constraints of the small footprint. As a debug tool, it is no bigger than a USB Stick - easily carried around with essential hacking tools. I have designed it as a socketable component that may be added to a board (see above) - where a small amount of intelligence is required, or for bridging between sensor devices. It can also collect or send data to SPI devices and bridge that back to the PC via the UART channel. Equally, it could be used as a small test equipment device to exercise, monitor or control prototype hardware - it has 16 GPIO lines - including two full SPI ports. These can be attached to the target hardware, and using the SIMPLEX scripting language, the various target hardware can be exercised and data reported back to the PC. With the right SIMPLEX script, it can be used to transfer a hex, bin or ascii file from the PC to the target under development. The external memory may be used for sensing and datalogging applications, capturing waveforms, playing back arbitrary waveforms - as a signal generator. The ADC channels may be used as a low bandwidth oscilloscope, test meter or for monitoring changing physical quantities in science experiments. ChipStick takes much advantage from the trend in modern sensors and peripherals to connect via the SPI or I2C bus. The MSP430FR2433 device provides up to 3 separate SPI buses. ChipStick can be interfaced to Wireless and WiFi modules such as the RFM69 via SPI and the low cost ESP-01 via the second UART port. Suitable sensors include accelerometers, gyroscopes, digital compass, temperature, pressure, loadcells etc. For basic GPIO operations - common shift registers may be used with the SPI bus such as the 74HC595 for 8-bits output - for driving LED arrays, the high power TPIC6B595 for driving stepper motors, and the 74HC165 for 8-bit inputs. Using a LED driver IC - such as the MAX7219 or AS1100 series - up to 8 digits or an 8x8 array of LEDs may be driven from the SPI port. OLED and LCD graphics displays may also be driven from SPI with a couple of control signals. Educational Applications ChipStick as been designed with education and experimentation in mind. It has been priced such that cost should not be a barrier to using it. The module can be made in China for as little as $4, and there may be a "kit" version available with just the awkward QFN-24 and SMT parts soldered to the tiny pcb, leaving the user add their own through-hole connectors - if needed. You can then use your own 3V3 programming USB-Serial lead. It can be used specifically to assist in the teaching of electronics, computer science and interactive coding. It is versatile enough to meet the needs of high-school and university undergraduates, plus simple enough meet the requirements of the maker and hacker community. The small size of ChipStick allows it to be used to give intelligence and connectivity in situations where other technology is just too bulky to fit - with the programmer section detached it is only 26.5 x 11mm - small enough to fit inside a 4x2 Lego block! It's low cost means that it can deployed in areas where other solutions might prove too expensive. Here are a few of the educational applications: Teaching Forth. Forth is an interactive language and can be best taught with hardware that creates a stimulating interactive environment. This includes the use of LEDs, sound, touch and movement (such as stepper motors and servos). The MSP430 is a good fit for a "traditional" Forth machine - with 16-bit Von Neuman architecture. MSP430FR2433 with 16K FRAM and 4K RAM is architecturally similar to the early minicomputers that Charles Moore would have first coded Forth onto in the late 1960s - just a bit faster. The external SPI memory has been included - specifically so that users can experiment and learn about interpreted languages running on virtual machines. OK - single byte access to external RAM takes approx 30uS - but block access is 3uS per byte. ChipStick will come with a 128Kx8 external SRAM 23LC1024, or FRAM to special order. The use of the 23LC1024 SRAM with its quad SPI port immediately opens up applications for logic analysers, dataloggers arbitrary waveform generators and other memory capture/playback devices. The SPI buses on the MSP430FR2433 allow expansion hardware like sensors and shift registers, LED and graphic display drivers etc to easily be added - with minimum of wiring. Teaching Coding ChipStick is not limited to Forth - it is easily programmed in C with CCS or Energia, BASIC or in native MSP430 assembly language. The SIMPLEX scripting language is written in C, easily modified and uses a Forth-like syntax. It encourages the use of short functions or blocks of code, that may be tried and tested individually by the interactive interpreter, edited if necessary and when fully working compiled and stored in the on-chip non-volatile FRAM. Code Blocks may then strung together to make more complex applications. An innovative but intuitive, cross platform GUI to visualise the process of coding is currently being developed. Teaching Digital Electronics ChipStick can animate electronic projects in a low cost way not previously possible. With a breadboard and a few LEDs and switches, ChipStick can form the central controller of many digital projects. It's ability to easily interface to displays, sensors and actuators allows it to make projects exciting. ChipStick can also be used to exercise digital electronics, and report results back to a PC for display on a graphical user interface. In teaching environments where real hardware may not be possible or practical - ChipStick can use virtual hardware and achieve most of the same educational aims. Creating Practical Hardware ChipStick helps to break down some of the barriers between modern electronic devices and practical hardware hacking. It's method of construction effectively converts between the awkward surface mount technology, and 0.1" (2.54mm) pitch pins - that are a lot more user and breadboard friendly. The small format and layout of the ChipStick board means that accessories and expansions may be easily prototyped on breadboard or stripboard at minimal cost, and then easily converted to a pcb - using tools such as KiCAD or EagleCAD. Simple designs can be created in a few hours, or over a weekend - with low cost pcbs delivered from China within a couple of weeks. ChipStick promotes the use of 50mm x 50mm expansion boards with a common header layout. This allows boards to be used together, shared or swapped between friends or whatever. Making and Hacking As a result of it's low cost, ChipStick can be used in projects where other solutions may seem over expensive. Projects no longer need to be stripped down, to salvage the only $20 Arduino for another purpose. ChipSticks will be supplied in multi-packs at very low prices - so that the cost of the device is no longer seen to be a barrier to creativity. ChipStick is compatible with Energia - an "Arduino Like" IDE. This allows an easy transition to the new device from familiar territory. ChipStick will enter production in the Summer. However - it is fully opensource, and the design files and firmware will be available via Github in due course. Happy Easter Ken London
  13. I'd tackle point 3 first. Sometimes you find that half the chip is not powered if you omit connecting a power pin - I read something of this nature in the datasheet or user's manual last week. Get you code to run first without the complications of LP modes - once it works at full speed - then you can add the niceties. Ken
  14. I have been intrigued with Forth since I was at school in the early 80s. There has been a renewed interest in Forth as a lightweight language with lightweight development tools - especially in these days of open source , where there is a backlash against the huge IDE tool chains needed to develop and debug code - even on the smallest of microcontrollers. As part of my recent investigation of MSP430 I have found a number of free, open source Forth implementations - which may be worth a look. 1. Fast Forth by Jean Michel Thoorens https://gitlab.com/Jean-Michel/FastForthForMSP430fr5xxx This is coded in MSP430 assembly language, is aimed at the newer MSP430 devices with FRAM and has the unique ability to mix Forth and asm in the source code. As a result of clever coding in asm - it really is fast, and has some nice features. It comes with an integral symbolic assembler, and support for accessing a SD card. It needs a minimum of 8K to 11K of FRAM - depending on the build options selected. It communicates with the PC using TeraTerm (or similar) at an astounding 921600 baud. It can load and compile Forth source code faster with a $2 USB- serial adaptor, faster than a FET can load a hex file. 2. Mecrisp - By Matthias Koch http://mecrisp.sourceforge.net/ Another Forth written in native MSP assembly language. (ARM Cortex version also available). Out of the box versions available for the following G and FR processors - plus a special for the MSP430F1612 on the G2 Launchpad MSP430F2274 (9600 Baud, 8 MHz, TX on P3.4, RX on P3.5) MSP430G2553 (9600 Baud, 8 MHz, TX on P1.2, RX on P1.1) MSP430G2955 (9600 Baud, 8 MHz, TX on P3.4, RX on P3.5) MSP430G2855 (9600 Baud, 8 MHz, TX on P3.4, RX on P3.5) MSP430G2755 (9600 Baud, 8 MHz, TX on P3.4, RX on P3.5) MSP430F5529 (115200 Baud, 8 MHz, TX on P4.4, RX on P4.5) MSP430FR4133 (115200 Baud, 8 MHz, TX on P1.0, RX on P1.1) MSP430FR5969 (115200 Baud, 8 MHz, TX on P2.0, RX on P2.1) MSP430FR6989 (115200 Baud, 8 MHz, TX on P3.4, RX on P3.5) Special Mecrisp for MSP430F1612 with initialisations for Launchpad hardware is included to conquer your Launchpad completely. Matthias is working on a version for the new ChipStick MSP430FR2433 device - see news in post below. 3. 4E4th by Dirk Bruehl & Michael Kalus http://www.4e4th.com/ An educational package aimed at high-school/university students or makers/hobbyists. Runs on G2 LaunchPad. Comes with a simple GUI to allow saving and loading of source code. Versions for FRAM based MSP430 devices available on request. Dirk Bruehl describes the package in his 2012 EuroForth conference paper http://www.complang.tuwien.ac.at/anton/euroforth/ef12/papers/bruehl.pdf 4. Camel Forth by Brad Rodriguez http://www.camelforth.com/download.php?view.32 Brad has written extensively about the mechanics of writing Forth interpreters over the years, and was probably one of the first to port Forth to the MSP430. It uses Mike Kohn's "Naken" lightweight cross assembler. There are other MSP430 Forth implementations available AmForth, eForth and MPE VFX Forth - with a cross platform GUI for Win, Linux and Mac OS X Ken
  15. Fred, It did actually start off at the other end of the board - which initially seemed a good idea at the time, but for tracking reasons, the SPI RAM needed to go there too - and in the end the RAM won the toss. With hindsight - it could be easily moved back again - now that all the traces are in place. Perhaps that's something for Issue 2. There are also 2 unused pins on the processor which could also be tracked out, a 24 pin DIL footprint might be a better overall size - allowing more features. This is a BSL programmer and comms interface - it is not a FET. If you want to do FET or SBW debugging then you need to use one of the more recent Launchpads (such as 4133 5739, 6869 etc) and connect 0V, /RST and TEST - that will allow SBW programming and debug. I have nothing against FET/SBW - except that it is a big lump on the end of a dev-board, and ChipStick is all about lightweight design. Having the USB interface detachable - but re-deployable by way of a cable and connector gives the greatest flexibility. Ken
  16. Roadrunner, The programming section is detachable. The pcb is perforated with a line of 0.5mm holes so that the end section can be cut off - or snapped off. With the programming section detatched, you can then use a 1.27mm connector pair and plug it back into the other end of the board. In effect, every ChipStick comes with a free programmer and USB-Serial converter. In the underside view, above, you see the CH340G (about $0.40) it's 12MHz crystal and a couple of 22pF capacitors. On the topside is the 3V3 voltage regulator and some more decoupling capacitors (10uF, 100nF). The programmer uses a 6 pin 1.27 mm connector - but NOT the pinout of the TI version - because if you get the TI connector in backwards you will fry your target. The connector looks like a half size FTDI pin-out (with the exception TEST is an output) and carries the following: 1 0V 2 TEST 3 VCC 4 RX 5 TX 6 /RESET TEST is driven from the DTR signal and /RESET is driven from the /RTS signal. Ken
  17. David, Thanks for finding this. Very interesting Clearly they share a common ancestor. The language is more Forthlike than mine, and more structured - possibly not a bad thing. I'm not really a programmer! I'll need to check out in full later. Ken I suspect he hasn't got 20 of these in his armoury though.....
  18. OK I started on the build this evening - should get this flashing a LED before sunrise. And I did! - code loaded by SBW, Uart connected, SIMPL running & LED flashing by 2am! Ken
  19. The pcbs arrived from my supplier today. Here's some rather grainy photos showing top and bottom sides against a millimeter rule. More photos later when I start to populate the board. Ken
  20. I think this new '2133 chip is targeted at smoke alarm applications. The TIA is just what is needed to convert the nano-amps from the ionisation chamber into a detectable change of voltage. At $0.60 in 1000off it's clearly aimed at high volume disposable products. I think you could just about run a Forth in 3.75K of FRAM Today I have just started looking at the MSP430i2041 which has 4 x 24 SD ADCs - aimed at 3 phase electricity metering applications. It's only $1.20 in 1000+ and makes the ideal smart analogue front end for loadcells, strain gauges, pressure sensors, altimeters or accelerometers. My only gripe is that I have to buy another schmartboard adaptor every time I want to use a TI chip in a breadboard. And very few of them share the same pin-outs. Its like you have to start all over again, each time you want to evaluate a new device. Ken
  21. Here's an interview with Ward Cunningham, from Portland OR - who developed the first Wiki - almost exactly 21 years ago. (March 25th 1995) He is also the creator of Txtzyme which was the inspiration for SIMPL. http://portlandcreatives.co/portfolio/ward-cunningham/ Ken
  22. Henk Sorry about the delay. I have now moved the SIMPL Wiki to my GitHub space You can view it here https://github.com/monsonite/SIMPL/wiki There have been some formatting issues when I transferred the files over which I still need to sort out. Also the project files are slowly being added to the repository https://github.com/monsonite/SIMPL regards Ken
  23. @@jazz talks about mailbox in posts #72 and #73 http://forum.43oh.com/topic/2972-sbw-msp430f550x-based-programmer/?p=53730
  24. Hi Jazz Your UART benchmark tests are most useful - thanks for sharing http://forum.43oh.com/topic/3413-msp430-uart-benchmark/ I found some interesting code by Rick Kimball - for low end MSP430 equipped with USI such as the the F2013 and the G2452 https://gist.github.com/RickKimball/1254043 By using software to add a start bit and stop bit to the output data of the USI shift register and setting the shift length to 10 - it is possible to transmit something that is like asynchronous uart data Rick states that the baudrate will be the same as the USI clock - so that could be up to the 16MHz limit - giving a theoretical 16 Mbaud. However most of the USB-Serial VCP devices such as CP2102, FT232 stop working at before 3Mbaud. Has anyone experimented with high speed SPI. What is the maximum clock speed? Is it possible to use extra GPIO lines to support QSPI or DSPI. The 23LC1024 SPI SRAM has both QSPI and DSPI modes and it would be nice to have faster access if this could be done easily. Ken
  25. Hi Spirilis, Most of the FRAM parts have 2x USCI A and 1 x USCI B. This allows you to use USCI A0 for your uart PC comms, USCI B0 for your SPI external memory which leaves USCI A1 for communicating with any other device you wish. Of course you can put multiple devices on a SPI bus - but I thought that to maintain memory bandwidth it was better to only put local memory devices on bus B. In theory - if you did have an array of these nano-processors - they could share memory devices - and as you only have 3 lines to handle - making a dual port memory from a serial device is fairly easy. The memory cycle time is fairly slow - about 3uS in streaming mode - but if you are interpreting some high level language like Forth, (particularly if it is written in machine code) then the overhead to do an off-chip fetch for the next Forth word is fairly low. The main point is the external memory gives you the flexibility to try these things - it's educational more than anything! You could even use the external memory as a monochrome video store, or holding audio samples etc, etc. For the sake of a $2 SRAM - it would be a shame not to have this fun extension. Ken
  • Create New...