Git Product home page Git Product logo

msp430-emulator's Introduction

MSP430 Emulator

You can use this emulator online now at: https://msp430.online

  • Providing a complete software model of the MSP430 16-bit instruction set

  • An interactive debugger for advanced development and in depth firmware/hardware analysis

  • Peripherals include:

    • GPIO Ports (LEDs and other pins)
    • UART Serial Communication (via USCI Module)
    • PWM Servo Motor Control
    • Timer_A (in progress)
    • BCM+ (in progress)

    The project goal is to emulate all peripherals and devices on the TI MSP430 Launchpad starter kit, to be able to run all firmware that would run on the physical device and programmatically test hardware inputs like UART / other digital ports. The emulator is written in C/C++ and acts as an API to the MCU.

    Please contact [email protected] if you are interested in using this tool for educational or industrial purposes. Thank you!

Interface.PNG


  • Build Instructions for API

    • Install dependencies via ./install_deps.sh
    • navigate to the root of the source tree
    • type 'make'
  • User Instructions for online interface

  • Documentation & Sample Programs:

  • TODO

    • Basic Clock Module / Timer
    • Instructions
      • DADD (BCD math)
      • RETI (Return from Interrupt)

msp430-emulator's People

Contributors

rudolfgeosits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msp430-emulator's Issues

compilation error under Xubuntu 16.04

It trows following warnings and error:

In file included from main.h:57:0,
from main.c:19:
debugger/websockets/emu_server.h:90:27: warning: ‘enum libwebsocket_callback_reasons’ declared inside parameter list
void user, void *in, size_t len);
^
debugger/websockets/emu_server.h:90:27: warning: its scope is only this definition or declaration, which is probably not what you want
debugger/websockets/emu_server.h:90:27: warning: ‘struct libwebsocket’ declared inside parameter list
debugger/websockets/emu_server.h:90:27: warning: ‘struct libwebsocket_context’ declared inside parameter list
debugger/websockets/emu_server.h:95:26: warning: ‘enum libwebsocket_callback_reasons’ declared inside parameter list
void *user, void *in, size_t len);
^
debugger/websockets/emu_server.h:95:26: warning: ‘struct libwebsocket’ declared inside parameter list
debugger/websockets/emu_server.h:95:26: warning: ‘struct libwebsocket_context’ declared inside parameter list
debugger/websockets/emu_server.h:97:38: error: array type has incomplete element type ‘struct libwebsocket_protocols’
static struct libwebsocket_protocols protocols[] = {
^
main.c: In function ‘main’:
main.c:80:3: warning: implicit declaration of function ‘display_registers’ [-Wimplicit-function-declaration]
display_registers(emu);
^
main.c:81:3: warning: implicit declaration of function ‘disassemble’ [-Wimplicit-function-declaration]
disassemble(emu, cpu->pc, 1);
^
Makefile:12: recipe for target 'main.o' failed
make: *
* [main.o] Error 1

How to give digital inputs via ports?

While using the emulator online, I could not give inputs to the microcontroller via S2 pushbutton on the launchpad. I could not find any interface to give digital inputs via the ports. Am I missing something?

No longer named MSPed

That name was much better. I can not see myself contributing to the project under the new name.

Incorrect handling of long jumps

Jump +778 jumps backwards.

devices/cpu/formatIII.c:decode_formatIII contains the following code:

  int16_t signed_offset = (instruction & 0x03FF) * 2;
  bool negative = signed_offset >> 9;
  
  char value[20];

  char mnemonic[100] = {0};
  /* String to show hex value of instruction */
  char hex_str[100] = {0};

  sprintf(hex_str, "%04X", instruction);

  if (negative) { /* Sign Extend for Arithmetic Operations */
    signed_offset |= 0xF800;
  }

The sign on bit 9 is tested after the offset is already multiplied by 2, without adjusting for the shift of one bit to the left, yielding an incorrectly negative value.

Multiplying the offset after the sign test and sign extension (with mask set to 0xFC00 to adjust) seems to work correctly and is more readable.

Emulator online but not working

@RudolfGeosits I just found this tool and I think is great. Unfortunately, I can't run either the examples provided here or the code I am compiling by myself. Is the tool online but not working or I am missing something? What is the process for running the examples or compiled code?

Thanks for the answer!

right shift issue

I think I'm running into a problem with the right-shift operation. It seems that the rrc operation in-fills zeros or ones, independently of the carry flag.

I'm trying to emulate the following C code:

#include <stdlib.h>
#include <stdint.h>

void xprintf(const char *fmt, unsigned int val)
{
    (void)fmt;
    volatile unsigned int xxx = val;
    (void)xxx;
}

int main(void)
{
    volatile uint16_t val1 = 0xf001;
    volatile uint16_t val2 = 0x4f85;
    xprintf("res: %#x\n", val1 ^ (val2>>4));

    return 0;
}

I think I run into a problem with the right-shift (val2>>4). This code is compiled as:

    c04a:       b4 40 85 4f     mov     #20357, -4(r4)  ;#0x4f85, 0xfffc(r4)
    c04e:       fc ff 
    c050:       1f 44 fc ff     mov     -4(r4), r15     ;0xfffc(r4)
    c054:       12 c3           clrc
    c056:       0f 10           rrc     r15
    c058:       12 c3           clrc
    c05a:       0f 10           rrc     r15
    c05c:       12 c3           clrc
    c05e:       0f 10           rrc     r15
    c060:       12 c3           clrc
    c062:       0f 10           rrc     r15

In the online emulator I get the sequence of values of:

0x4f85
0xa7c2
0xd4e1
0x69f0
0xb4f8

I.e. sometimes I get a zero infill, sometimes I get a 1 infill, even though the carry flag should be cleared by the clrc instruction.

I compile with msp430-gcc version 4.6.3:

msp430-gcc -mmcu=msp430g2553 -O0 -g -W -Wall -std=c99   -c -o main.o main.c
msp430-gcc -mmcu=msp430g2553 -O0 -g -o firmware.elf main.o

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.