C programming on Mac or PC

Discussion in 'Mac Programming' started by Piplodocus, Jan 10, 2010.

  1. Piplodocus macrumors regular

    Apr 2, 2008
    Hello. I'm doing C programming at uni in my electronics degree. At uni we use PCs and a program called Code Composer for writing the code, then compile and load it onto a texas instruments (USB) microprocessor development board to run it/debug it, as an embedded program. I can only use the board while at uni (1 day a week), so with the busy timetable and me working full time the rest of the week I don't get much chance to work on any programs. All the coding is very simple plain C, with no user interface (it's all ran using stdio.h I/O) and no object-oriented stuff.

    Question: Can I use Xcode on the mac, or MS Visual Studio on the PC to run plain C code and see the I/O results? Or is there any other software I can use? I'm not using any commands that are specific to that board (until next year sometime) and just want to be able to run simple C code, input variables, and see the output.

    Any help?
  2. Sander macrumors 6502

    Apr 24, 2008
    Code Composer is Texas Instruments' IDE for embedded development. Apart from a "normal" C compiler (which targets their DSP etc.) it also has a cycle-accurate simulator.

    But as long as you don't use any DSP-specific functionality, you can compile your code just fine on other compilers. The question is, though, are you sure you're not using this? Normally, you write embedded software to use I/O which is specific to the DSP, and you often even have a (small) chunk of hand-written assembly to set up all the devices in your board.

    It's probably best to simply take all your code and try compiling it elsewhere. All the "special stuff" will have no meaning on anything other than your development kit (e.g., to set up certain ADC channels, you'll have to write special values to "magic" memory addresses). On your "normal" computer, these writes at best will not have any meaning, or at worst will trigger bus errors or segmentation faults.
  3. Piplodocus thread starter macrumors regular

    Apr 2, 2008
    Thanks! I now have the code running in XCode. Yay!

    I started as a new project, and chose "Command Line Utility" and "Standard Tool" as the project type. Then added my whatever.c file, which includes main () and any other functions called.

    I figure I have to press the "Console" button to see the Standard IO screen. Then press "Build and Go" and voila; it runs, and I see it happening in the "Debugger" console.

    How can I watch different variables whilst it's running though? I've found the Variables View in the menu, but everything is greyed out apart from the top "Enable Data Formatters", and I can't click on watch variable or anything else that seems likely? Any clues?

    Also can I run in a step mode to step through lines of code, or do a "Run to here" type command?

    Sorry if any of these questions seem a bit stupid, everything seemed more obvious in the code composer at uni (I just show the watch window and it displays all variables current states, and there's nice big step buttons on the thing)!

Share This Page