Programming in ANSI C - Also need something like HyperTerminal

Discussion in 'Mac Programming' started by ryanparanich, Dec 8, 2010.

  1. ryanparanich, Dec 8, 2010
    Last edited: Dec 8, 2010

    ryanparanich macrumors newbie

    Joined:
    Jul 21, 2010
    Location:
    Can't say
    #1
    I'm an electronics engineering student. One of our courses is basic C programming for microcontrollers.

    For the quick and important chunk, check out the bottom, the middle here is going to be all descriptive content, in case there is something there that can help you help me.


    I'm currently running a iMac, 27", i7, 8GB RAM, 2TB HD, etc etc. Probably doesn't help...

    Our board is the MSP430FG4618, made by Texas Instruments. (if that helps) See some info here.

    I'm programming in ANSI C, and currently (at school on the PC) using a 9 pin serial connection to run output back to the computer. It has I/O through USB connection, I don't know why we don't use output through the USB, but that's just the way it is...

    We're using hyper terminal to display text and instructions, and get input. Our instructor created his own stdio library variation. Honestly, if you have suggestions on how I can just make it simpler, I'm all ears. we use xprintf() instead of printf(), I don't care which way I type things in, so long as it's ansi c and it runs.


    Basically, I need to program in ANSI C, compile and run it, and I need some kind of terminal window where I can see the text that the program outputs, and enter input that the program will then accept and process. Simple right?

    Your help is truly appreciated. It may make the difference between me passing or failing... So I really really appreciate it.
     
  2. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    The Terminal app is in your Mac's /Applications/Utilities folder. Install the free optional Developer Tools or Xcode download from developer.apple.com, and you will have an ANSI C compiler that you can run from the Terminal command-line.
     
  3. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #3
    I might suggest wrapping his non-ANSI (somewhat ironic) calls around the standard one for testing and fallback.

    Code:
    if (xprintf != NULL) {
         xprintf("something");
    } else {
         printf("something");
    }
    
     
  4. autorelease macrumors regular

    Joined:
    Oct 13, 2008
    Location:
    Achewood, CA
    #4
    I don't understand, is this C code supposed to run on the microcontroller board? If so, you can't use the C compiler that comes with the Developer Tools. You'll have to install an MSP430 toolchain, like MSPGCC. (http://mspgcc.sourceforge.net/)

    jared_kipe, your code will fail to link if xprintf() is not defined. You'd have to use preprocessor macros.
     
  5. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #5
    You would need to declare the function as extern, possibly in a header you only include through preprocessor macros, the compiler will fill unlinked addresses with NULL.

    This is straight from apple's developer page. I suppose maybe apple provides some magic to make it work, but since it is for C functions it can't be that impressive on the back end.

     
  6. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #6
    Install MacPorts and install minicom from there. That will act as a terminal program. With it, you can interact with a serial port like you can in Hyperterminal.
     
  7. autorelease macrumors regular

    Joined:
    Oct 13, 2008
    Location:
    Achewood, CA
    #7
    Interesting. I vaguely remember hearing that, the linker on OS X does lots of magic and I'm not sure how much of it is cross-platform. Usually, instead of checking for the availability of individual functions, you check for a platform-specific define (__GNUC__, __APPLE__, etc.), but I'm not sure this suffices for all cases.

    You might not need to install minicom: Mac OS X comes with screen, which can be used to connect to a serial device like this:
    Code:
    screen /dev/cu.usbserial 38400
    where /dev/cu.usbserial is your serial port device and 38400 is the baud rate. To exit, press Control-a followed by Control-\. As far as I can tell it doesn't allow your to set any of the other serial parameters (parity, stop bits, etc.), though.
     
  8. Flynnstone macrumors 65816

    Flynnstone

    Joined:
    Feb 25, 2003
    Location:
    Cold beer land
    #8
    I'm from Edmonton, cool.

    I have a 24" iMac and develop for the Freescale HCS12.
    Maybe not what you want to hear, but I run Parallels with windows XP.
    I use Hyper Terminal too.
    There's not a lot of support for embedded development on the Mac.

    If you do this, I recommend 8 G of memory.
     
  9. ulbador macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #9
    +1 to this except replace Parallels with VirtualBox. I've honestly found it to be superior to Parallels in many ways and it's free!
     
  10. bubulindo macrumors member

    bubulindo

    Joined:
    Jul 16, 2010
    Location:
    Neither here, nor there...
    #10
    Serial Tools

    I'm an electronics engineer myself and work on microcontrollers. You can use the screen command from the terminal, but the software I use is Serial Tools.

    http://homepage.mac.com/chen/w7ay/Serial Tools/index.html

    You can download the source code or the package to install. Give it a go.
     
  11. jabbott macrumors 6502

    Joined:
    Nov 23, 2009
    #11
    The USB line is probably just used to flash the microcontroller, whereas the 9-pin serial connection is allowing you to interact directly with the MSP430's UART. Something like minicom would help, but you still need to find a way to convert the serial data to USB. An FTDI serial to USB module might help.

    In terms of compiling, you can't just use gcc from Xcode to compile executables for the MSP430, as it is only configured to generate binary code for the Intel x86 architecture. You will need something like MSPGCC, which may or may not run on OS X (I haven't tried it before), and it may not support the exact variant of MSP430 you have.

    Honestly it would be easier to use something like VirtualBox and use the TI software, as others have suggested. Even then you may need to use the FTDI module to send and receive to the MSP430 UART. TI's Mac support is severely lacking, despite customers complaining to them about it for years.
     

Share This Page