Search the Community

Showing results for tags 'MSP430G2553'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Found 117 results

  1. i bought two Mspexp430 launchpad with two cc110l rfand i could to programm them in energia : then i want to add more nodes on the Network so i bought two new Mspexp430 launchpad with new two cc110l rf and they work correctly on ATC boostersatcklite but when I want to program them on energia I can upload the code but the cc110l doesn’t exchange any data from each other , i tried also with the examples in energia (wirlessControl-WirlessTest-WirelessMonitorhub-WirelessmonitorSensor) but they did not work Can you help me to let them work correctly and exchange data
  2. I'm working on a project where I need to oscillate at 25khz. I've been using the PWM built into the MSP430G2553 and it doesn't seem to be accurate enough to give me exactly 25khz. I've been getting anywhere from 23khz to 27khz and cannot figure out why it's off by so much. I might be doing something wrong. Does anybody know what sort of accuracy I should expect from the on board PWM in the MSP430G2553. Is there a way to make it more accurate? I was looking at adding an external crystal, but would rather not add that complication if it isn't necessary.
  3. Hi, I just noticed an excessive consumption of ram by Wire on G2553 (I did not test on other µC) : 400 bytes !! I took a look at Wire.h but can't find where this memory is used. If anyone can confirm this and/or have an idea about this issue ? Regards
  4. Overview dAISy (do AIS yourself) is a very simple AIS receiver that I developed from scratch. It is built around the Silicon Labs EZRadioPRO Si4362 receiver, using a Texas Instruments MSP430G2553 MCU for processing and the MSP-EXP430G2 v1.5 LaunchPad as development platform. The complete project source code and schematics are available on GitHub: https://github.com/astuder/dAISy Update 5/18/2015: A finished, self-contained AIS receiver based on this project is now available for purchase on Tindie. AIS, short for Automatic Identification System, is a standard for tracking ships. Ships advertise their position, course and other information with short transmissions on specific frequencies (161.975 MHz and 162.025 MHz). More on Wikipedia. An AIS receiver, like dAISy, receives and decodes AIS transmissions. It then re-packages the raw data into NMEA sentences (specifically formatted ASCII strings). Finally, using a serial connection, these strings are forwarded to more capable equipment for further processing. If you're the lucky owner of a tricked out boat, you could connect dAISy to your navigation computer. For land lobbers like me, a more common use case is to run naval mapping software that supports AIS data input on a PC. In the screenshot below I've connected dAISy to OpenCPN (link), an open source chart plotter and navigation software. On the top right you can see my setup war-driving at the Seattle waterfront as my lab is too far from the coast to receive anything. The LaunchPad sits on the dashboard with a white USB cable connecting to the notebook computer in the foreground. dAISy's data is fed into OpenCPN, bottom right shows a log of the serial data received. OpenCPN maintains a database of all the collected data (lower left) and visualizes nearby ships on a map (top center), including past and projected course. Hovering the mouse over a ship will display its name (text on yellow ground) and clicking it will reveal more detail (top left). Hardware I wanted to build my own, non-SDR, AIS receiver for a long time. There are a few projects floating around the internet (e.g. here) which refer back to an article by Peter Baston, published 2008 in Circuit Cellar magazine (copy available here gone.. google for Peter Baston Circuit Cellar to find other copies). Unfortunately, the CMX family of modem ICs by CMS Microcircuits (link) used in these projects are relatively expensive ($15+) and hard to find for hobbyists. In addition you'd need a radio to do tune into and down-convert from the ~162 MHz carrier frequency. So I was quite excited when earlier this year a parametric search on Mouser brought up a new IC that covered the required range (162 MHz) and modulation (GMSK). And best of all, available in single quantities for $3.56 $2.27 $2.22! (link) The Silicon Labs EzRadioPRO Si4362 (link) is a single chip receiver that covers frequencies from 142 to 1050 MHz and supports various modulations, including GMSK. It comes in a tiny 20-pin QFN package and the only external parts required are a 30 MHz crystal, an antenna with a few capacitors and inductors for impedance matching, and finally some decoupling caps and pull-down resistors. Time to whip up a breakout board. I used the opportunity to give KiCad a try and quite like it. Here's the schematic: And the layout: I used OSHPark to make the PCBs. At a smidgen over one square inch it cost $5.15 for 3 copies: http://oshpark.com/shared_projects/QUWi71r4 Note that the layout still has three issues that I already fixed in the schematic: GPIO0 and GPIO1 were flipped SDO required a pull-down resistor as the radio leaves it floating when not actively sending, which confused the hell out of me while trying to figure out the communication protocol. Lastly, the holes for the headers turned out to be slightly too small to comfortably fit the cheap breakout headers I had at hand. Edit: Here's Rev B where I fixed these issues: http://oshpark.com/shared_projects/WI6u3Qmk Which brings us to the BOM: Silicon Labs Si4362 (U1) 30 MHz crystal (X1)Si4362 datasheet specifies <11 pF load capacitance, but a crystal specified for 12pF load capacitance seems to work fine too Antenna/LNA matching network, calculated based on SiLabs AN643 (link, approx. values, +/- 5% shouldn't matter too much):75 ohm (dipole): 10 pF (CR1), 5 pF (CR2), 280 nH (LR1), 200 nH (LR2) 50 ohm: 12 pF (CR1), 6 pF (CR2), 240 nH (LR1), 160 nH (LR2) Decoupling caps:100 pF, 100 nF, 1uF (C1, C2, C3) Pull-down resistors100 k (R1, R2) First thing I noticed when I received the parts: The 20-pin QFN at 4x4 millimeters is tiny! I mounted it by first tinning the pads with a small quantity of solder. I then added flux and placed the chip on the pad. I then used a hot air station to carefully reflow the solder. Worked the first time around. After using jumper wires to figure out how to talk to the chip, I mounted the breakout board on a makeshift BoosterPack using perfboard, double-sided tape and wire (see picture at the top of the post). Here's how I ended up connecting the breakout board to the LaunchPad / MSP430G2553: SEL -> P1.4 (SPI chip select) SCLK -> P1.5 (SPI CLK) SDO -> P1.6 (SPI MISO) SDI -> P1.7 (SPI MOSI) GPIO0 -> P2.0 (I/O unused) GPIO1 -> P2.1 (I/O clear-to-send) GPIO2 -> P2.2 (I/O RX clock) GPIO3 -> P2.3 (I/O RX data) SDN -> P2.4 (shutdown / reset) IRQ -> P2.5 (I/O channel-clear) Software The software of dAISy consists of three major blocks: Radio configuration and control over SPI Packet handler, including a basic FIFO for received messages NMEA encoding and transmission to the PC over UART For UART (TX only) and SPI (TX/RX) I use the MSP430G2553's USCI A0 and B0 respectively. In both cases I don't use interrupts which simplifies things considerably. Upon reset the following steps happen: Initialize MSP430 peripherals Initialize packet handler, which will also reset FIFO Initialize and configure of radio, which will also setup SPI Start packet handler, which will also put the radio into receive mode And in the main loop: If debug messages are enabled, poll packet handler for status and errors and report them over UART Check FIFO for new packets If there is a new packet, invoke NMEA processing (which sends the message over serial to the PC) and remove packet from FIFO Below follows a more detailed discussion of the radio integration and the implementation of the packet handler. Radio The communication with the radio is vanilla SPI using 4 wires: MOSI (SDI), MISO (SDO), CLK (SCLK) and CS (SEL). I used the MSP430's USCI B0 to implement SPI and a separate pin to control CS. The only tricky thing to figure out was, that the Si4362 keeps the MISO line floating unless it actively transmits data. This is unfortunate as the master is supposed to poll for a specific response (FF) to detect when the radio is ready to receive more commands. This is easily fixed by adding a weak pull down resistor to SDO. I did this on the board, but it probably also works with using MSP430's internal pull-down. Additional lines I used to control the radio are: SDN to reset the radio CTS, which by default is mapped to the radio's GPIO1, indicating that the radio is ready for the next command While taking up an extra pin, CTS turned out to be much more convenient than the SPI response code to properly time communication flow with the radio. In dAISy, I wait for CTS to go high after each command to ensure the radio completed its task. The communication protocol is quite extensive but well documented: EZRadioPRO API Documentation describes the complete API and all registers AN633 Programming Guide for EZRadioPro Si4x6x Devices describes how to use the API in common scenarios Both are available on the Si4362 product page (link), under Documentation > Application Notes and are still updated quite frequently. The radio is set up by dumping a large configuration sequence into it. This includes configuration of radio frequency, modulation, GPIO pins and more. This information is stored in radio_config.h, which has to be generated with a tool called WDS (Wireless Development Suite). WDS is available in the Tools section on the Si4362 product site. Above are the settings I used for dAISy. WDS will use this information to configure various amplifiers, filters, clocks and decoding algorithms inside the chip. As Si4362 supports GMSK encoding only indirectly (see this thread), I'm certain there's more optimization potential by tweaking registers, but that's currently way beyond my knowledge of RF theory. While the Si4362 comes with its own packet handler, it unfortunately does not support NRZI encoding (Wikipedia). So I set up the radio to expose the 9600 baud clock and received data on separate pins and implemented my own packet handler. Packet Handler The packet handler (inspired by Peter Baston's implementation) is implemented as a state machine that is invoked on each rising edge of pin P2.2 which receives the data clock. There are 5 main states: Off, no processing of incoming data Reset, start from anew, either on start up or after successful/failed processing of a packet Wait for Sync, waiting for a training sequence to arrive (010101..) and start flag (01111110), implemented with its own state machine Reset, start new preamble 0, last bit was a zero 1, last bit was a one flag, training sequence complete, now process start flag Prefetch, ingest the next 8 message bits to ease further processing Receive Packet, process bits until the end flag (01111110) is found or an error situation occurs Independent of state, the interrupt routine continually decodes NRZI into actual bit sequence. In the "Receive Packet" state there's continuous calculation of the packet CRC and some bit-de-stuffing. When the end flag is found and the CRC is correct, the received message is committed into the FIFO. If an error is encountered, the bytes already written to the FIFO are discarded. In both cases, the state machine starts anew by transitioning into RESET. This reads like a lot of code for an interrupt handler. However with the MCU running at 16MHz even the most complex state only uses a fraction (<10%) of the available time. Future Improvements Lastly a list of things I'd like to improve with the next version of dAISy. Software: Receiving on both AIS channels through channel-hopping done 1/5/2014 Tweak radio settings for better sensitivity and lower error rate LED(s) for indicating reception of valid/corrupt packets Hardware: Proper antenna connector Layout PCB as BoosterPack and/or USB dongle Receiving on both AIS channels at once with two radio ICs -- edit 12/25: replaced original post with high-level project description, more detailed documentation of implementation to come -- edit 12/28: added documentation for hardware (here and on Github), fixed some typos -- edit 12/31: added documentation for software and list of future improvements -- edit 01/05: implemented channel hopping (change to state machine) -- edit 01/15: changed state machine to reflect recent changes (see post further down for details), added link to shared project on OSHPark -- edit 01/25: major rework of sync detection state machine
  5. I'm new to MSP430 and I'm trying to do a frequency/period measurement. I've read about timers and get the main concepts though I'm still learning. To get an idea of how they work, I'm using this code. It outputs a PWM on one pin which I connect to another pin for capturing period: http://coecsl.ece.illinois.edu/ge423/datasheets/MSP430Ref_Guides/Cexamples/MSP430G2xx3 Code Examples/C/msp430g2xx3_ta_21.c After making some modifications (removing unneeded code to light led and adding calculations for frequency) it works with the original pins. However, I want to change which input pin will take measurements. I want pin 2.0 to do so. Currently, TimerA0 captures and TimerA1 outputs PWM. Since PIN 2.0 uses TimerA1 and not A0, I assumed I would just need to flip the timers and pins. However, it's not working. I looked at the datasheet and can't figure out whats wrong. What am I missing? Here is my code: #include <msp430.h> unsigned char Count, First_Time; unsigned int REdge1, REdge2, FEdge; int main(void) { unsigned int Period, ON_Period; unsigned char DutyCycle; WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer // P1SEL |= BIT0; if (CALBC1_8MHZ==0xFF) // If calibration constant erased { while(1); // do not load, trap CPU!! } DCOCTL = 0; // Select lowest DCOx and MODx settings BCSCTL1 = CALBC1_8MHZ; // Set DCO to 8MHz DCOCTL = CALDCO_8MHZ; // Configure Port Pins P1DIR |= BIT2; // P2.1/TA1.1 Output P1SEL |= BIT2; // TA1.1 Option select P2DIR &= ~BIT0; // P1.1/TA0.1 Input Capture P2SEL |= BIT0; // TA0.1 option select // Configure TA1.1 to output PWM signal // Period = 82/32khz = 2.5ms ~ 400Hz Freq TA0CCR0 = 82-1; // Period Register TA0CCR1 = 21; // TA1.1 25% dutycycle TA0CCTL1 |= OUTMOD_7; // TA1CCR1, Reset/Set TA0CTL = TASSEL_1 + MC_1 + TACLR; // ACLK, upmode, clear TAR // Configure the TA0CCR1 to do input capture TA1CCTL1 = CAP + CM_3 + CCIE + SCS + CCIS_0; // TA0CCR1 Capture mode; CCI1A; Both // Rising and Falling Edge; interrupt enable TA1CTL |= TASSEL_2 + MC_2 + TACLR; // SMCLK, Cont Mode; start timer // Variable Initialization Count = 0x0; First_Time = 0x01; while(1) { __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 __no_operation(); // For debugger // On exiting LPM0 if (TA1CCTL1 & COV) // Check for Capture Overflow while(1); // Loop Forever Period = REdge2 - REdge1; // Calculate Period ON_Period = FEdge-REdge1; // On period DutyCycle = ((unsigned long)ON_Period*100/Period); } } // TA0_A1 Interrupt vector #pragma vector = TIMER1_A1_VECTOR __interrupt void TIMER1_A1_ISR (void) { switch(__even_in_range(TA1IV,0x0A)) { case TA1IV_NONE: break; // Vector 0: No interrupt case TA1IV_TACCR1: // Vector 2: TACCR1 CCIFG if (TA1CCTL1 & CCI) // Capture Input Pin Status { // Rising Edge was captured if (!Count) { REdge1 = TA1CCR1; Count++; } else { REdge2 = TA1CCR1; Count=0x0; __bic_SR_register_on_exit(LPM0_bits + GIE); // Exit LPM0 on return to main } if (First_Time) First_Time = 0x0; } else { // Falling Edge was captured if(!First_Time) { FEdge = TA1CCR1; } } break; case TA1IV_TACCR2: break; // Vector 4: TACCR2 CCIFG case TA1IV_6: break; // Vector 6: Reserved CCIFG case TA1IV_8: break; // Vector 8: Reserved CCIFG case TA1IV_TAIFG: break; // Vector 10: TAIFG default: break; } } I checked and there is a pulse going into P2.0 but P2.0 is not capturing it. Is it just not possible with this pin or am I missing something obvious?
  6. Hi, I am using MSP430 launchpad with G2553 controller. When I am using sleep(5000), and varying the voltage on the controller from 3v to 4v the timing is varying based on the voltage, but the timing in not changing when I am using delay(5000) when I am varying voltage. Any help will be appreciated. Regards,
  7. Hi Everybody, I've been developing some code on Linux using CCSV7.2 and I already know that CCS will not program the g2553 like it would on a Windows box. But, I know that you guys are clever! How have you been programming and debugging the g2553 on Linux these days? Are you using a different LaunchPad and hot wiring it over to the G2553 LaunchPad?
  8. I wrote a sketch to fire 2 outputs back and forth with a pot to adjust the on time of the outputs and a pot to adjust the off time. The outputs are just LEDs for now and there is a 3rd LED that turns on when either output is on (so I can adjust the pots later when the outputs are only driving silent, solid state relays.) Every time the MSP430G2553 is powered up or reset, in the Launchpad or a bread board, all of the pins configured as outputs go high for about a second before the program starts to run There is a thread that comes up with a google search of the problem where everyone just accepts that this is what the MSP430 does but it seems to be something that the underlying Energia code is doing because the C code does not make this happen. I altered the Blink source file in CCS to make the 2 onboard LEDs toggle back and forth. When the board is powered up running that code, both outputs don't go high. The LEDs just start to toggle back & forth as programmed. Has anyone else dealt with this? I really can't have all the outputs turn on at the same time with my project. Is there a way to write the Energia sketch to avoid this or do I have to learn how write my code in C? I hope you can excuse my ignorance. I just started trying to program a week ago. I took it up to make this one project when I decided it was going to be a little too complicated to build with discrete components. I really appreciate any help/advise.
  9. Hello everyone. I'm a beginner and doing some project with the MSP430 2553. I connected the MMA7455 and used different libraries to get some data, but I'm doing something wrong. Perhaps I use the wrong ports, or the wrong configuration, or I don't know what I'm missing. With the libraries I get to show text in the terminal, but the values are always 0. I would be grateful if someone could help me out, I'm for days on this problem. SCL -> 1.6 SDA -> 1.7 Libraries I used: https://playground.arduino.cc/Main/MMA7455 https://arduino-info.wikispaces.com/accelerometer-MMA7455 Attached is the doc. MMA7455L.pdf
  10. I was trying to port a sketch that used the Serial port with non standard UART parity and character length to Energia. I noticed that the UART port isn't setup to handle anything except 8-N-1. While the code below can't do all the combinations that are available to the atmega, it can do 7/8 bit, even/odd parity and 1/2 stop bits. I created a patch that will at least fix it for the chip I am using (msp430g2553). It will need some work for other chips. Apply the attached patch to the source of the latest Energia source tree. (as of 11/11/2015) -rick (See new optional second parameter https://www.arduino.cc/en/Serial/Begin ) parity.patch
  11. 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
  12. Nick Gammon published an interesting post on using SPI on 16 MHz Arduinos to run WS2812 LEDs (aka neopixels) at: http://gammon.com.au/forum/?id=13357. He also provides a link with a lot of information about the NRZ protocol used by the WS2812 and tolerances: https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/. The tolerances are actually quite a bit looser than what I previously believed. So, I set out to do something similar with Energia and LaunchPads running at different speeds. Spoiler alert: It works. The previously linked articles provide all the background so minimal information is repeated here. NRZ is a one wire protocol that transfers information to the LEDs by varying the length of the signal when high. A longer pulse is used for a 1, and a shorter one for a 0. The timing, with tolerances, is shown in the figure below. The length between pulses cannot exceed about 5 us and most everything else is pretty loose. The protocol is implemented using SPI which I find pretty clever. A byte is sent out with the SPI module with the proper length to represent the desired bit for the protocol. The following must be determined and set to do this: Set proper SPI clock speed using SPI.setClockDivider() in Energia Determine the proper byte to send by SPI.transfer() in Energia to represent a 0 or 1 bit For example, using the MSP430F5529: Clock speed is 25.6 MHz Setting the SPI clock divider to 4 gives a SPI clock of 6.4 MHz and since the SPI block executes in one cycle (Arduino executes in 2), each bit in the byte is equivalent to 156.25 ns. Therefore, to send a pulse indicating a "1", a byte equal to 0b1111000 could be used which gives 4x156.25 = 625 ns. This is in the acceptable range of 550 to 850 ns. Similarly, for a 0 an acceptable byte would be 0b11000000 or 312.5 ns. A similar process can be used to determine acceptable values for the MSP430G2553. The sketch below is a simplification of the library presented by Nick which and includes the modifications described above to run on both the G2553 and F5529. The preprocessor is used to set appropriate values for the clock divider and long and short bytes. The functions are very nearly the same as posted by Nick. Note that interrupts must be disabled before sending data and then reenabled manually after. /* * WS2812 display using SPI on various TI LaunchPads with Energia * * Connections: * LaunchPad LED Strip * --------- --------- * 3V3 5VDC * Pin 15 (MOSI) DIN * GND GND * * How to use: * ledsetup (); - Get ready to send. * Call once at the beginning of the program. * sendPixel (r, g, ; - Send a single pixel to the string. * Call this once for each pixel in a frame. * Each colour is in the range 0 to 255. Turn off * interrupts before use and turn on after all pixels * have been programmed. * show (); - Latch the recently sent pixels onto the LEDs . * Call once per frame. * showColor (count, r, g, ; - Set the entire string of count Neopixels * to this one colour. Turn off interrupts before use * and remember to turn on afterwards. * * Derived from NeoPixel display library by Nick Gammon * https://github.com/nickgammon/NeoPixels_SPI * With ideas from: * http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/ * Released for public use under the Creative Commons Attribution 3.0 Australia License * http://creativecommons.org/licenses/by/3.0/au/ * * F Milburn November 2016 * Tested with Energia V17 and WS2812 8 pixel strip on launchpads shown below. */ #include <SPI.h> #if defined(__MSP430G2553) #define SPIDIV SPI_CLOCK_DIV2 // 16 MHz/2 gives 125 ns for each on bit in byte #define SPILONG 0b11111100 // 750 ns (acceptable "on" range 550 to 850 ns) #define SPISHORT 0b11100000 // 375 ns (acceptable "on" range 200 to 500 ns) #elif defined(__MSP430F5529) #define SPIDIV SPI_CLOCK_DIV4 // 25.6 MHz/4 gives 156.25 ns for each on bit in byte #define SPILONG 0b11110000 // 625 ns (acceptable "on" range 550 to 850 ns) #define SPISHORT 0b11000000 // 312.5 ns (acceptable "on" range 200 to 500 ns) #else #error This microcontroller is not supported #endif const unsigned int PIXELS = 8; // Pixels in the strip void setup (){ ledsetup(); } void loop (){ // Show a solid color across the strip noInterrupts(); // no interrupts while sending data showColor (PIXELS, 0xBB, 0x22, 0x22); // single color on entire strip interrupts(); // interrupts are OK now delay(1000); // hold it for a second // Show a different color on every pixel noInterrupts(); // no interrupts while sending data sendPixel(0xBB, 0x00, 0x00); // red sendPixel(0x00, 0xBB, 0x00); // green sendPixel(0x00, 0x00, 0xBB); // blue sendPixel(0xBB, 0xBB, 0xBB); // white sendPixel(0xBB, 0x22, 0x22); // pinkish sendPixel(0x22, 0xBB, 0x22); // light green sendPixel(0x22, 0x22, 0xBB); // purplish blue sendPixel(0x00, 0x00, 0x00); // pixel off interrupts(); // interrupts are OK now delay(1000); // hold it for a second } // Sends one byte to the LED strip by SPI. void sendByte (unsigned char { for (unsigned char bit = 0; bit < 8; bit++){ if (b & 0x80) // is high-order bit set? SPI.transfer (SPILONG); // long on bit (~700 ns) defined for each clock speed else SPI.transfer (SPISHORT); // short on bit (~350 ns) defined for each clock speed b <<= 1; // shift next bit into high-order position } // end of for each bit } // end of sendByte // Set up SPI void ledsetup(){ SPI.begin (); SPI.setClockDivider (SPIDIV); // defined for each clock speed SPI.setBitOrder (MSBFIRST); SPI.setDataMode (SPI_MODE1); // MOSI normally low. show (); // in case MOSI went high, latch in whatever-we-sent sendPixel (0, 0, 0); // now change back to black show (); // and latch that } // end of ledsetup // Send a single pixel worth of information. Turn interrupts off while using. void sendPixel (unsigned char r, unsigned char g, unsigned char { sendByte (g); // NeoPixel wants colors in green-then-red-then-blue order sendByte (r); sendByte (; } // end of sendPixel // Wait long enough without sending any bits to allow the pixels to latch and // display the last sent frame void show(){ delayMicroseconds (9); } // end of show // Display a single color on the whole string. Turn interrupts off while using. void showColor (unsigned int count, unsigned char r , unsigned char g , unsigned char { noInterrupts (); for (unsigned int pixel = 0; pixel < count; pixel++) sendPixel (r, g, ; interrupts (); show (); // latch the colours } // end of showColor The timing, when checked on a logic analyzer, checks out with the calculations above (hooray for math). The "gaps" between pulses are within tolerance and largely set by code overhead as well as the byte being sent. And here it is showing the strip lit up in one color. I tried this on several other LaunchPads I had handy and here is a summary: FR6989 - I had never noticed, but Energia defaults to 8 MHz. Doing the math, there isn't a good match to the WS2812 requirements without changing processor speed (which I did not try). MSP432 - there was behavior I couldn't explain, probably due to RTOS and I didn't pursue this for long. In summary, the method works although I did limited experimentation. It would be even easier to implement outside of Energia with full access to clocks. It was an interesting exercise but alternative methods have been posted here on 43oh with tuned assembler and having used those successfully in the past, I will probably continue to preferentially use them in the future.
  13. Do you have date time to introduce support for C++11 as introduced to ESP8266/ESP32 on ARDUINO IDE. Thank you for your help example: namespace { enum class STATES_MSP: std::uint8_t { MSP_Sleep,MSP_Poweron,MSP_PIR_Alarm,RTC_Alarm,ESP_Power_off,ESP_Heartbeat,ESP_Power_on }; };
  14. I'd like to monitor power and indicate to the user of my device when power is getting low (via flashing LED). Does MSP430G2553 support power monitoring and does the Energia library have any tools to access this monitoring?
  15. Seems to me that I2C is a fairly commonly used way to communicate between MSP430G2553 and various sensors. However, I cannot seem to find a standard library that implements it. There are many home spun implementations and there doesn't seem to be a standard I2C Library. I'm VERY NEW to the embedded development world, but have been a windows programmer for 20 years. I'm used to having standard reusable libraries that do the grunt work for me so I don't have to re-invent something that has been done by others 100 times already... Am I just missing something or are all embedded developers just masochists?? Surely not.. So, does anybody know where I can find a simple I2C library that works with my MSP430G2553 in Code Composer Studio 7? Any reason why it isn't just built in? Or is it? This is a huge paradigm shift for me, so please be patient. Any help would be appreciated.
  16. Hi, Is there a ready library for PID control available for MSP430F5438A or G2553 controllers. Please help if an example is available for the same. Thanks, Tanmay
  17. Good Morning, This may be the wrong place to ask this question. If so, please let me know where to ask it.. I've been a Windows programmer for 20 years. I've pretty much stuck to User Interface development the whole time. I have been using .net and C# for the past 10 years so I am VERY SPOILED when it comes to letting the language do the grunt work and I finesse the code. I now find myself working on a personal project which requires me to program the MSP430G2553 controller. I started out by using Energia (which if you don't know, is a fork off of Arduino) The advantage of it is you can do a lot with very little code and without needing to know all the guts of the MSP430G2553. The disadvantages are that sometimes it doesn't work right. Sometimes it doesn't give you the control you need, sometimes it's hard to figure out if Energia isn't working, or if your code isn't working... Anyway, I've spent hundreds of hours getting parts of my program to work. I have been trying to get away with not having to learn how to write firmware and have to deal directly with the processor. However, I'm starting to think that I need to bite the bullet and take the time to overcome my learning curve and dive in headfirst to firmware development and the paradigm shift that comes with it. The program I am using needs to have control over changing into and out of the various Low Power Modes on the MSP430. I need to listen for interrupts. I need to use I2C to communicate with various devices that are connected to the MSP430. I need to monitor Power Level/Consumption from time to time. So, basically, I have the following questions: 1. Can Energia robustly and without errors do the above things? 2. Am I wasting my time getting all of the above accomplished using Energia? 3. Should I be using Code Composer Studio? 4. Having NEVER developed ANY controller level code outside of Arduino and Energia, what kind of Learning Curve am I looking at to accomplish the above things? 5. Where is the best place to start learning this? 6. Where is the best place to look for answers to MSP430 development questions? Thank you all in advance for any assistance and advice you might have.
  18. I'm writing my own i2c library and need to be able to simultaneously change PinMode on 2 pins. One for SCL and one for SDA. Is there a way to change PinMode on 2 pins simultaneously? I want the behavior of the follwing: PinMode(14,OUTPUT); PinMode(15,INPUT); without the 2.5microsecond delay between the 2 calls above.
  19. After making the wearable MSP430 for Halloween this year I was requested to make more for a children's dance group. I have a question, but first some background. This is the latest version: Everything works fine. I use an adapter with pogo pins to program it as shown in the photo. There are three LEDs on the PCB, a push button switch for the user, and more accessible pins than the previous version. Parts are TSSOP and 0805 SMD. Snap fasteners and stainless thread can be used to connect it to LEDs on the costume. A CR2032 coin cell is used to power it (coin cell holder is on the backside of the PCB). So far that has been sufficient and the light weight and inconspicuous nature has been advantageous for the small children it is intended for. Now a new upgrade has been requested... add a radio so that multiple units can be synched and/or controlled offstage. Here is a rough list of requirements: must be inexpensive - current materials for 10 units is less than $5. I want to keep it under $10. keep SMD parts large enough to be hand soldered keep using CR2032 (rated 3V and 225 mAH) The MSP430G2553 and LEDs are currently using no more than 20 mA on average - to be safe assume 40 mA Unit needs to run at least half an hour on fresh batteries Unit needs reliable radio reception at 10m with clear line of sight Unit will need to receive only - no transmission. Reception updates required close to continuously - say every 100 ms keep PCB to the same size - 40mm/1.6" diameter needs to be programmable in Energia I have a fair amount of time - 6 months to get it working I have looked at several different radios but the two that I have experience with are the nRF24L01 and CC2650. I am ruling out the CC2650 due to cost. There is a small version of the nRF24L01 that is shown below for scale along with the more commonly seen version: I think I can shift things around and make this fit. Connection is by the castellated edge facing forward on the photograph. The datasheet states 13.5 mA RX at 2Mbps air data rate. That is in the range of what I have seen as well so it looks like it would meet the requirements. Here are my questions: 1) Is there another radio I should be looking at? Maybe one made by Hope. 2) I have no design experience with radios but could I use an off the shelf design and put the radio, bits, and PCB trace antenna on the PCB myself? I would probably have to give on the 0805 parts size criteria. 3) Any other thoughts, comments, and suggestions appreciated. This will be an open source design and anyone who wants to contribute or have the design is welcome EDIT: the material cost is on a per unit basis
  20. So, I've read the threads and have made things work once, but now, without seeming to have changed anything, I'm getting code that goes into never-never land.. In twi.c, around line 607 in Energia version 17, I get a lockup in the first while statement: #if defined(__MSP430_HAS_USCI__) || defined(__MSP430_HAS_USCI_B0__) || defined(__MSP430_HAS_USCI_B1__) /* Ensure stop/start condition got sent before we exit. */ if(sendStop) { while (UCBxCTL1 & UCTXSTP); // end with stop condition } else { while (UCBxCTL1 & UCTXSTT); // end with (re)start condition } #endif I've been trying different recommended suggestions all over the place and had it working about 60 minutes ago, but then I tried and moved some code around and now I can't get it to work anymore... I put all the code back the way it was, and NADA... still not working... Is it just a time of day thing or am I the only one who can't seem to have any consistency in the I2C behavior...? By the way, I'm using an MSP430G2553 chip with 32 pins in the QFN configuration. I really did have this working an hour ago and cannot for the life of me figure out why it stopped working. Any hints would be GREAT.. By the way, the reason I'm not using Energia Version 18 is because it isn't supported in Code Composer Studio yet.. Anybody know when that support will appear? Thanks for any help you might have to offer, Curtis Please see my Pins_energia.h file below: /* ************************************************************************ * pins_energia.h * * Energia core files for MSP430 * Copyright
  21. ?Hello, I am trying to upload a "Blink" program to my MSP-EXP430G2. I have no problems uploading code successfully through Code Composer Studio. But if I try to update the same code through Energia, it won't work. The error message is: usbutil: unable to find a device matching 0451:f432 An error occurred while uploading the sketch I have checked that the port number and board are correctly selected. Could anyone offer any help troubleshooting this? I want to use Energia over CCS, mainly so I can quickly and easily get a read-out of the serial port. But if anyone knows of an easy-to-setup way to read the serial port, then I could always just upload code via CCS and be done with it! Many thanks in advance for any help offered. Eddie
  22. Ok, so I've changed over to an MSP430G2553IRHB32R Controller. This is in the QFN 32 pin package. According to it, P1.6 is for SCL I2C and P1.7 is for SDA I2C. On the 20 pin board, they are pins 14 and 15. On the 28 pin board they are pins 22 and 23. On the 32 pin board they are pins 21 and 22. So, I'm trying to use the simple I2C Scanner and get nothing. I have 2 I2C devices attached, but cannot see either of them. There have been many posts about inserting a Wire.write(1); command and copying updated files into the system. I'm using the latest Energia 18 on a Windows 10 machine. I'm using LaunchPad 430 to program my custom board which has the MSP430G2553IRHB32R controller on it. Seems like any time I attempt to use a different board, I have problems with the Wire library. It seems to hang up during the endTransmission call. I've tried 'SetModule(0)' and that doesn't work either. I've checked the Pins_Energia.h file to make sure the pins were correct. So, all that being said, Should I keep up the battle with Wire.h, use a different I2C library, or just write my own I2C library? As I work with firmware more and more, I have a growing respect for those of you who live in that world. You guys are amazing !!! I appreciate any help you are able to offer to get the I2C working on my custom board. Thanks, Curtis
  23. Edit 09.12.2016: I added Arial_16x24.h and Arial_24x40 (really a 24x36, but I had to keep a multiple of 8), digits only, created with GLCD Font Creator (I had to edit the result slightly manually). See images below. So I can confirm that adding any further fonts created with GLCD Font Creator works (I run it on Linux on wine BTW) and is only limited by how much fits into the SSD1306_OLED_5x8_11x16_16x24_24x36_fonts.zip
  24. MSP430 based Nixie tube clock. I was looking for some nice Nixie tube digit images so I could add them to my EduKit library, but I couldn't find any usable ones. I decided to just buy few of them and photograph myself. Then I thought that it would be a horrible waste if they just sit in a drawer. So here it is, my first Nixie project since... 1987. This clock will be available as kit, but since this is v1, I will most likely make some adjustments. Any suggestions are welcome.
  25. I'm trying to use a Launchpad 430 to program a board that has an MSP430G2553IRHB32R. I am doing this on a Windows 10 machine. I've removed the jumpers on the Launchpad and connected VCC and Ground to the other board. I've also connected RST and TEST pins. I created a simple blinky sketch which runs just fine with a stand alone Launchpad 430. However, when I attempt to program my custom board with the same code, I get the following error. MSP430_GetNumberOfUsbIfs MSP430_GetNameOfUsbIf Found FET: HID0003:COM5 MSP430_Initialize: HID0003:COM5 Firmware version is 20409001 MSP430_VCC: 3000 mV MSP430_OpenDevice tilib: MSP430_OpenDevice: Could not find device (or device not supported) (error = 4) tilib: device initialization failed the selected serial port tilib: device initialization failed does not exist or your board is not connected I have selected the MSP-EXP430G2553LP board and COM5. I cannot seem to get it to program my other board. I've tried several different USB cables. Used 2 different computers and 2 different Launchpads. I even attempted to program a different custom board that I had been able to program before. I'm using the latest version 18 of energia. Can somebody point me in the right direction as to how to solve this problem and be able to program my custom board? After that, does anybody know what I need to do to get the board.txt and pins file set up to work correctly with my 32 pin MSP430G2553... chip? Thanks for the help, Curtis