programming 101 - Page 1
Forum section: electronics / general

author: kjn4685
author_rank: Regular Contributor
timestamp: November 16, 2014, 09:34:09 pm
content: Well guys I want to start learning to program a microcontroller. So I want to know if I can build my own programmer can it be done and if someone out there has a schematic I would appreciate it very much. I have never programmed anything ever. So I mite have a lot of help.Thank you in advance.

author: IanB
author_rank: Super Contributor
timestamp: November 16, 2014, 09:40:07 pm
content: Do you mean you have never written any computer programs? Because programming a microcontroller can mean two different things. It can mean sending an existing program over the wire and storing it in a microcontroller for execution. Or it can mean writing the program code that the micro will later execute.If you have never written any program code before and you want to learn, you should pick a learning environment with ready made hardware so that you only have one thing to learn at a time. For instance you could try beginning with an Arduino, or you could try learning to program on a PC first.

author: kjn4685
author_rank: Regular Contributor
timestamp: November 16, 2014, 09:56:18 pm
content: Well yes I have written in basic about 25 year's ago. I had a ti computer I don't know if you know what that is. It came out about 1985 it was made by Texas instruments. Was interfaced with a tv.

author: IanB
author_rank: Super Contributor
timestamp: November 16, 2014, 10:14:03 pm
content: Quote from: kjn4685 on November 16, 2014, 09:56:18 pmA TI-99/4A?I still would suggest getting your feet wet with an Arduino and working up from there. There's no shame in starting at the beginning.

author: kjn4685
author_rank: Regular Contributor
timestamp: November 16, 2014, 10:28:06 pm
content: I agree you are right so I will do that and thank you very much for your help.

author: hamster_nz
author_rank: Super Contributor
timestamp: November 16, 2014, 10:28:35 pm
content: Quote from: IanB on November 16, 2014, 09:40:07 pmPart of me thinks that programming on a PC (or Android) has become too complex. For me, small projects on a microcontroller like an Arduino would be the best place to learn to elementary programming if you also had an interest in electronics too.To be an interesting learning experience there must be a purpose behind it (be that to blink an LED, make a beep or to build robot, a simple burglar alarm...), rather than doing something where there is a $2 app for that.In general Arduinos are a mighty fine platform to start programming in C - in my opinion far better than Visual Studio Express.

author: dannyf
author_rank: Super Contributor
timestamp: November 16, 2014, 10:36:28 pm
content: QuoteI would start with C on a PC. Get yourself a modern IDE, like Code::Blocks.Once you have mastered C, move to CB + gcc-avr or Atmel's compiler for AVR.

author: kjn4685
author_rank: Regular Contributor
timestamp: November 16, 2014, 10:42:54 pm
content: My other question is can I build my own programmer. Like the pic 2 or some other programmer.

author: Hideki
author_rank: Frequent Contributor
timestamp: November 16, 2014, 11:07:04 pm
content: You can, but that type of in-circuit-programmer is based on a microcontroller, so how do you intend to program the programmer to make it work as a programmer?

author: dannyf
author_rank: Super Contributor
timestamp: November 16, 2014, 11:12:23 pm
content: Before you think about building your own programmers, you will need to think about which mcus to learn on. AVRs / PICs are quite popular. PICs have a larger installed base so lots of code, but quite antiquated hardware. AVRs are more popular and have more compiler / ide support, particularly due to the arduino crowd. Both are good to learn on.If I were to start today, I would probably pick PIC24, or STM8. The 32-bit chips are considerably harder for a beginner.You can build your own programmers. But you may not find it helpful - the commercial programmers are fairly cheap - mostly free or < $5 for AVRs, and $20 - 30$ for the PICs. Free or $5 for STM8.Your tools are the last thing you need to worry about so I would say, at least when you start out, go with a commercial / pre-built programmer instead. Of the PIC programmers, I would go with a PICKIT2, unless you are dying to try out the newer chips.

author: hamster_nz
author_rank: Super Contributor
timestamp: November 16, 2014, 11:15:11 pm
content: Quote from: kjn4685 on November 16, 2014, 10:42:54 pmSure you can, but it is not like the old days when you could bit-bang a parallel port or serial port programmer. Most solutions usually they involve a microcontroller that needs to be programmed with software that is somewhat complex to write yourself. So you will need to at least borrow a programmer to bootstrap the process.You can even use one Arduino as an ISP programmer to program other Arduinos (http://arduino.cc/en/Tutorial/ArduinoISP).However, an ready-made inexpensive programmer might allow such things as debugging that can be tricky to impossible on a roll-your-own programmer.But is it really worth it? You could pick up something like a TI Stellaris Lunchpad (http://www.ti.com/tool/ek-lm4f120xl) for $13, and it includes a USB interface that support the standard on-board Stellaris in-circuit debug interface?The TI parts are pretty good value - For $13 you get a 32-bit ARM Cortex-M4-based microcontroller with 256 kB Flash memory, 32 kB SRAM, 80 MHz operation, USB host, device, and OTG connectivity, and if you want it to be more Arduino-like you can always use Energia (http://energia.nu/)

author: zapta
author_rank: Super Contributor
timestamp: November 16, 2014, 11:34:18 pm
content: OP, get an arduino uno and you will have all the tools needed to program and run microcontroller programs. In addition you will find tons of examples on the internet and books and a vibrant community and you will have a free world class C/C++ compiler.

author: miguelvp
author_rank: Super Contributor
timestamp: November 17, 2014, 12:55:56 am
content: Not for microcontrolers but for C/C++ programming you can get the full Visual Studio Professional Edition for free with the Microsoft Visual Studio Community 2013. Also supports Python, HTML5, JavaScript, C#, VB, and F#.https://www.eevblog.com/forum/chat/visual-studio-community-2013-a-full-featured-ide-free/msg550822/#msg550822Add the 20 free seats for Perforce source control and you are using a professional environment. I know you can use CLang on VS so there is no reason you couldn't use a third party compiler,debugger,deployment toolchains with that offering, but I haven't look into that yet.Maybe too much of a tool for a beginner.

author: westfw
author_rank: Super Contributor
timestamp: November 17, 2014, 12:57:25 am
content: Note that if you do get an arduino (which I agree is a good starting place, probably), then you should get an "Uno" class board, which doesn't need an external programmer of any kind (just plug it into a USB port and you're good.) After you progress a bit, the Uno can be used AS A PROGRAMMER for programming other devices.

author: DG41WV
author_rank: Regular Contributor
timestamp: November 17, 2014, 01:52:16 am
content: Quote from: Hideki onTodayat 05:07:04 AMI usedthisprogrammer to program my pickit2 firmware. the programmer is just 8 diodes and a resistor and a capacitor connected to a parallel port.

author: dannyf
author_rank: Super Contributor
timestamp: November 17, 2014, 11:27:15 pm
content: Which boards to get is quite dependent on what you're trying to do. Within the arduino world, I would get an atmega32u4 based board - Leonardo - for its analog module.For arm boards, I would go with the f3 discovery or nuclei boards, for its analog functions, or the f4 discovery or nuclei boards, for speed.The ti board is very feature rich but a little buggy.

author: SirNick
author_rank: Frequent Contributor
timestamp: November 18, 2014, 12:12:11 am
content: The Arduino Uno is the de-facto choice for learning microcontroller development. It's cheap, ubiquitous, there are tons of demos and books and tutorials, the community's vibrant, there are tons of hardware add-ons, and when/if you blow up the chip, you can snap in a new one and off you go. (Just make it a point to try out the Arduino-as-ISP sketch and burn the bootloader to a few bare ATmega 328P chips before you damage the one you have.)

author: kjn4685
author_rank: Regular Contributor
timestamp: November 18, 2014, 03:23:04 am
content: Hey. Thanks guys

author: Alex30
author_rank: Regular Contributor
timestamp: November 18, 2014, 03:38:42 am
content: When I got into microcontrollers I didn't bother with arduino and all the rest of it. They are great platforms but I wanted a more bare bones experience of working from the ground up. I picked up one of thesehttps://learn.adafruit.com/usbtinyisp/overview. I really love it. Very easy to use and quite cheap. Plus you can use it for an easy +5V from your usb port. Works with almost any AVR chip. I started with an ATMega32 and just did this tutorialhttps://www.newbiehack.com/MicrocontrollerIntroductionABeginnersGuidetotheAtmelAVRAtmega32.aspx. Which pretty much set me up and on my way to doing lots of different projects. Good luck!

author: janengelbrecht
author_rank: Regular Contributor
timestamp: November 18, 2014, 04:27:12 am
content: The small problems with Arduino:1) The programming language is in essence C - the Arduino language is merely a set of C/C++ functions that can be called from your code. Your sketch undergoes minor changes (e.g. automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-gcc+). In general it is not as efficient as the code made in avr gcc+/WinAvr alone.2) The Bootloader takes up flash code space.3) Because you are not close to the microcontrollers hardware (register setups etc.) it can be a problem to switch to another microcontroller / IDE / compiler if all you know is the Arduino environment.When all is said and done...the speed by which youre on your way and making code that works in the Arduino world is extreme compared to other environments...and other architectures.You could stay in the Arduino world and make professionel results if you should wish so. (Arduino Due is an ARM based processor that means you can come a long way .... and there is the posibility to use a few other ARM based hardware boards too!). And all the above will never be a problem.....too small code memory because of bootloader ? Choose an Arduino MegaWhen all works...you just copy the board hardware to your own design: its open hardwareBut go for the Arduino first.... in time when your skills are grown i would try some more advanced stuff as somebody has mentioned before me...Myself ? I started with Z80 on a Sinclair computer (ZX81 i think the name was) - moved on to Intel 8031 - further on to Motorola 6800 - 68000 - Intel 8086/80286/80386/80486 - Siemens 80535 - Atmel AT89C51 - Atmel AVR - Atmel ARM and now i seem to be stucked thereA journey that took about 30 years

author: John_L
author_rank: Contributor
timestamp: November 18, 2014, 07:14:03 am
content: There is a PIC32 based small computer "Maximite" programmed with BASIC interpreter, very similar to 1970s/80 Commodore 64, ZX81 etc. Also a PIC32MX150/170 microcontroller "Micromite" with BASIC interpreter with number of modern functions, PWM, I2C, SPI, 1-WIRE, etc.You would need to consider carefully where you want to go in the future, as Basic will not exactly lead you to programming in C.http://geoffg.net/maximite.htmlhttp://www.thebackshed.com/forum/forum_topics.asp?FID=16

author: miceuz
author_rank: Frequent Contributor
timestamp: November 18, 2014, 07:56:00 am
content: I've started teaching an Arduino programming course now and I must say, it's not that easy to teach programming on a microcontroller. My students don't have any programming experience, so it's not just programming microcontrollers, but programming in general.The main problem I stumble on with Arduino are various inconsistencies. Like, why do I have to write Serial.begin() why upper case, why dot, why make such a basic functionality as a class? It creates unnecessary complexity - some "special case".Another thing I've noticed is that my students declare pin as an input via pinMode(pin, INPUT) before doing analogRead() on it. Well, I can't blame them - I've said you have to declare pin as input before reading from itanother special case - you don't have to declare pin as input before analogReading from it. But you still have to declare pin as an output before analogWriting to it.The list goes on. Sometimes I think it would be easier if I would just teach them low level peripherals and register access.Arduino is great for copypasting soething quickly, I myself do use it for prototyping and small noncritical projects, but for teaching / learning programming -- unfortunatelly no, its API is just an inconsistent mess.

author: dannyf
author_rank: Super Contributor
timestamp: November 18, 2014, 11:39:33 am
content: You can code an arduino board as if it is an avr, with all the glories of using registers.The beauty of using an arduino board is their abundance of shields and low prices.

author: westfw
author_rank: Super Contributor
timestamp: November 18, 2014, 01:30:46 pm
content: QuoteYes; this. "So hard to remember that you were trying to drain the swamp, when you spend all your time fighting alligators."Unfortunately, a lot of "beginning programming" instruction for non-microcontroller environments has the same sort of problem, with the basic principles getting obscured by attempts to make the programs look like the snazzy GUI interfaces that people see as USERS. Bring back the days of "program myprogram(input, output)" where most of what you did was neither input nor output (and thus those could be provided by assorted external mechanism.)

author: SirNick
author_rank: Frequent Contributor
timestamp: November 18, 2014, 07:44:14 pm
content: I tend to agree that programming microcontrollers is probably not the best way to start programming in general. However, here are a couple counter-arguments to that:1) PC environments are a lot more complicated than they use to be. If we assume Windows, then your obvious choice is Visual Studio Express. It's not terribly hard to use, but there's a little bit of a learning curve in figuring out an IDE (any IDE really) since all your options are right there all at once. And while many C books start you out with:Code:int main (int argc, char *argv[]) {printf("Hello world\n");}... on Windows, you get all that char vs. tchar vs. wchar vs. whatever, for one of many such examples. The first time I created a console project in VS, I was stuck for days trying to figure out how I'm supposed to deal with characters, since obviously Windows had it's own way of doing things that did not look like the examples in your typical book. Having never really learned Windows programming, I'm still not sure of the right way to do many simple things because of architectural differences from the basic, portable coding practices that have been the staple of tutorials since C was created. (I've actually helped a couple new Arduino users who couldn't figure out why the compiler kept complaining that DWORD was undefined. I'm in a similar boat, but in reverse.)IMO, Linux is a better environment for learning C, since it actually looks like normal C, but that could be personal bias. Writing code in a simple text editor and then running gcc from the command line made it really easy to write my first working program, but you do have to consider the learning curve of an alternate OS as well -- which is not nothing.In contrast, the Arduino IDE is stupid simple (in good and bad ways), there's zero tool-chain setup, and you can write and upload your first program within minutes of downloading the software.Either way, you have to learn to code, but keeping the "other stuff you have to know" down to a minimum is a plus.2) The biggest aid in learning anything is motivation. If you're terrifically bored by writing four-function calculators and array sort routines, you may never get through a programming book. OTOH, if you can write five lines of code and get a blinking LED, that might be enough to hook you. It's a long journey either way, but if you're excited to take that journey, you'll actually do it.So, while programming on a PC first is probably academically beneficial, if your goal is to nurture an enjoyable hobby, you might opt to go for the route that is most engaging.

author: IanB
author_rank: Super Contributor
timestamp: November 18, 2014, 10:57:42 pm
content: Quote from: SirNick on November 18, 2014, 07:44:14 pmIt's really not so complicated. The Windows extensions are just that--extensions--not differences.If you write standard C in Visual Studio the compiler will compile and run standard C. It is a standards conforming compiler.See the attached screenshot, for example.

author: hamster_nz
author_rank: Super Contributor
timestamp: November 18, 2014, 11:57:41 pm
content: Quote from: IanB on November 18, 2014, 10:57:42 pmIf I was interested in Electronics and programming, with minimal existing skills in either, my preference would be: Arduino, then Linux on Small ARM board (e.g. Pi), then PC Linux and finally Windows.Solid example - creating a burglar alarm alarm for a reed switch on a door, and make a noise when it is open. Code to support it1. Arduino - nice and simple - and fully understandable.Code:setup(){PinMode(1,INPUT); -- to switch in door;PinMode(2, OUTPUT); -- to beeper}loop(){if(DigitalRead(1) = 0){// Waggle the beeperDigitalWrite(2,1);delay(1);DigitalWrite(2,0);delay(1);}elsedelay(1);}2. On small Linux box, after a bit of cut-and-paste from various pages. Quite a bit of black magicCode:#include <stdio.h>#include <unistd.h>#include <stdlib.h>#define MODE_FILE_FORMAT "/sys/devices/virtual/misc/gpio/mode/gpio%d"#define PIN_FILE_FORMAT "/sys/devices/virtual/misc/gpio/pin/gpio%d"int main(int c, char *v[]){char buffer;FILE *modefile, *pinfile;int pin;if(c != 2) {fprintf(stderr,"usage: %s \n",v);exit(2);}pin = 1;/* Open the GPIO control files */sprintf(buffer,MODE_FILE_FORMAT,pin);modefile = fopen(buffer,"w");if(modefile == NULL){fprintf(stderr,"Unable to open mode file: %s\n",buffer);exit(2);}sprintf(buffer,PIN_FILE_FORMAT,pin);pinfile = fopen(buffer,"r");if(pinfile == NULL){fprintf(stderr,"Unable to open pin file: %s\n",buffer);exit(2);}/* Set the pin to be an input pin */fwrite("0",1,1,modefile);/* Read and display the value of the GPIO pin */while(1){char buffer;fseek(pinfile, 0, SEEK_SET);if(fread(buffer,1,4,pinfile) <= 0) {fprintf(stderr,"Error on read\n");break;}if(buffer = '0')system("aplay alarm.wav");usleep(100000);}fclose(modefile);fclose(pinfile);return 0;}3. On PC Linux box, just like 2, but with no Hardware GPIO pins to play with, so find something likehttp://numato.com/32-channel-usb-gpio-moduleand adapt the code to it. A bit more black magic and very few hits in Google for howtos.4. On WindowsFirst, work out what you are trying to do (which is hard when you don't know what you are doing)Then find and buy a GPIO board - which will cost more than an Arduino.Then read a lot on how to access the GPIO pins (usually involves importing DLLs and other tricks) and custom setting in the build environmentThen work out how to play sounds through the Win32 API multimedia interfaceThen work out how to use timers to check the pin at regular intervals.Then finally start writing code - something as newbie-incomprehensible as this, but would include calls to "PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME);" and some thing to do the timer.Then write code like this, where the actual code that does real work ("SetPinLevel(133, 0);") looks pretty much the same as the Arduino code:Code:using System;using System.Linq;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices; ///< To use Toradex C Win32 DLLsnamespace GPIO_LED{public partial class Form1 : Form{[DllImport("GPIOLib.dll", CharSet = CharSet.Auto)] ///< Importing DLLpublic static extern bool SetPinAltFn(Int32 pinNum, Int32 altFn, bool dirOut); ///< External function declaration[DllImport("GPIOLib.dll", CharSet = CharSet.Auto)]public static extern void InitGPIOLib();[DllImport("GPIOLib.dll", CharSet = CharSet.Auto)]public static extern bool SetPinLevel(Int32 gpioNum, Int32 val);[DllImport("GPIOLib.dll", CharSet = CharSet.Auto)]public static extern void DeInitGPIOLib();public Form1(){InitializeComponent();SetPinAltFn(133, -1, true); ///< To set the SODIMM_133 as GPIO output}private void button1_Click(object sender, EventArgs e){SetPinLevel(133, 1); ///< Sets SODIMM_133 as high when button1 is pressed}private void button2_Click(object sender, EventArgs e){SetPinLevel(133, 0); ///< Sets SODIMM_133 as low when button2 is pressed}private void FormClose(object sender, EventArgs e){DeInitGPIOLib(); ///< Deinitializes GPIO library and frees up system resources upon closing the program}}}Which takes me back to my original advice - if you want to play around with programming and electronics then don't use your PC - buy and Arduino starter kit.

author: zapta
author_rank: Super Contributor
timestamp: November 19, 2014, 12:11:42 am
content: If you get the Arduino Uno, get also this excellent book.http://exploringarduino.com/http://amzn.com/1118549368

author: IanB
author_rank: Super Contributor
timestamp: November 19, 2014, 12:58:27 am
content: Quote from: hamster_nz on November 18, 2014, 11:57:41 pmLet me fix this for you:QuoteIf you are an absolute beginner, then you can't avoid figuring out where to begin, on any platform.Also, I don't understand why you have used simple C style programming on Linux, but have passed that by on Windows and gone for something very complicated and obfuscated instead? Especially when my prior post showed that free Windows tools support standard C console programming perfectly well.QuoteYour point may be perfectly valid, but that's not news since I pointed to the Arduino in Reply #1 right at the top.On the PC, you can learn to program. To program, note. Not necessarily learn to interface to external hardware. That's a different dimension.

author: SirNick
author_rank: Frequent Contributor
timestamp: November 19, 2014, 01:14:55 am
content: Quote from: IanB on November 18, 2014, 10:57:42 pmOK, but taking the char stuff for example, what are the limitations of using char[]? Most of the tutorials I see have the T() macro and all kinds of other crazy stuff going on, plus all these API calls ending in _A and _W. I assume things aren't much different provided you stick to ASCII <127, but I have no idea what happens to international characters in filenames or text strings.Advice I've read online varies from "don't bother -- just use char[]" to "always use t_char, stay away from w_char" to "never use t_char, only use w_char" to "depends on whether you've defined UNICODE". Then, there are the file I/O functions. I'm sure open() and read() -- or fopen() and fread() -- do exist, but there are a whole slew of C API functions native to Windows that appear to be preferable, given the examples online.I'm sure I'm making it worse than it needs to be, but I'm ignorant of why there are so many ways to do the same thing, and therefore, what those things do differently to warrant their existence.In Linux, you just use plain old C. If large character sets are necessary, it's probably in UTF8 and can mostly be ignored unless you're mangling text yourself.

author: IanB
author_rank: Super Contributor
timestamp: November 19, 2014, 01:24:57 am
content: Quote from: SirNick on November 19, 2014, 01:14:55 amIn Windows also, unless you have a specific reason to do otherwise, just use plain old C.There are no limitations of char[] that you need care about. The char data type stores 8 bit bytes and will handle ASCII text. If you are a native English speaker, and have no special need for extended character sets or Unicode, then you can pretend Unicode doesn't exist. (Unless you happen to open a file that was saved by another program with multi-byte character encoding, but that will mess with you on Unix just as much.)If you want or need to interact with the Windows APIs for graphical programming, then you may need to start caring. But I write nearly all my experimental C and C++ programs as simple text console programs that use standard input and standard output. I just use the standard language features and everything is hunky dory.

author: miguelvp
author_rank: Super Contributor
timestamp: November 19, 2014, 01:41:43 am
content: char can handle EFIGS languages if you use what people call the ANSI char set, so you are good for English, French, Italian, German & Spanish. But that's no longer the case and UTF8 is wasteful for some languages while wide chars with UTF16 is not (although it would be wastefull for just EFIGS implementations).tchar allows you to have code that will support wide characters without changing anything other than defining UNICODE. Would that be complicated to a beginner? maybe, but then again if that's how it is done then a beginner will learn it that way 8 bit chars are fading to a thing of the past.As for Arduino for a beginner, I don't buy that it's hard to figure out what you want to do, we all started from the beginning and we managed just fine, the Arduino IDE enables rookies to get a lot of things done without a lot of complications, just like when someone discovered how powerful a peek and a poke where back in basic and we didn't have any trouble figuring how the interrupts worked and i/o etc.The ramp up time to get things done in an Arduino is orders of magnitude lower (as in faster) than other platforms, I will dare to say that it's easier than basic back in the days where you had to learn about the bios and what addresses did what and call those from your assembly code because memory restrictions and there was code in the bios that will do what you wanted to do. Now we have libraries and a ton of them so there is more flexibility and we have better documentation.As far as windows, if you think it's complicated give the windows 8 api a try. Even for experienced windows programmers it's a big leap but at least it's more asynchronous processing friendly and complicated just translates to job securityEven as much as people moan about COM it's better than CORBA and even if I hate that marshalling is going on behind the scenes, it allows your code to scale on multi core/multi processors and it's able to give you more concurrency on your code.Also there are so many samples out there for anything that learning any of them is really not an issue, but just do something instead of thinking that it's hard to do.Edit: objects are rest, just want to keep on resting, once they are in movement, they just want to keep on moving

author: zapta
author_rank: Super Contributor
timestamp: November 19, 2014, 01:58:22 am
content: Quote from: janengelbrecht on November 18, 2014, 04:27:12 amThat's incorrect, Arduino gives you full avr GCC c/c++ and you can write your code as efficient or low level as you want.

author: hamster_nz
author_rank: Super Contributor
timestamp: November 19, 2014, 01:58:43 am
content: Quote from: IanB on November 19, 2014, 12:58:27 amGoogle for "wIndows GPIO programming in C" and see what you get - I get answers for the BeagleBone Black before I get any usable Windows Code!Maybe I should have instead used WindowsCE code (that I guess won't run on a PC) - it has at least a dozen lines that look like ANSI C, most of them the ones with just a brace on it:Code:#include <Windows.h>#include <GPIO_API.h>int WINAPI WinMain( HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow){HANDLE hGPIO_API;DWORD count;RETAILMSG( 1, (TEXT("Testing GPIO\n")));hGPIO_API = InitGPIOAPI();if( hGPIO_API != INVALID_HANDLE_VALUE ){SetOutputGPIOPin( hGPIO_API, 30 );for( count = 0; count < 20; count++ ){SetGPIOPin( hGPIO_API, 30 );RETAILMSG( 1, (TEXT( "set GPIO 30 is %s\r\n"), ReadGPIOPin(hGPIO_API, 30)?TEXT("Set"):TEXT("Clear")));Sleep( 1000 );ClearGPIOPin( hGPIO_API, 30 );RETAILMSG( 1, (TEXT( "clear GPIO 30 is %s\r\n"), ReadGPIOPin(hGPIO_API, 30)?TEXT("Set"):TEXT("Clear")));Sleep( 1000 );}DeinitGPIOAPI( hGPIO_API );}RETAILMSG(1,(TEXT("Done\n")));return 0;}Rant mode on. Having done *a lot* of C programming on Windows, going back to using WinSock() under Windows 3.0, I find systems programming C on Windows is an abhorrence. Well, maybe that is a little strong, but it sucks big-time.Have you ever tried to write a true Windows service? ever tried to receive and send data to/from a Serial Port while also doing other stuff? writing network services that need to service multiple sessions? Process multiple file streams at once? accessing physical disks devices to query their size? ever used shared memory and other IPC? And then accessing GPIO, DACs or ADCs where no standard API exists? It is a bit like the Chewbacca Defence - "To learn to use C on a platform where the underlying system APIs are not compatible with the native C paradigm - it does not make sense! you must acquit!"Yep, I'll agree that the random nature of IOCTLs are a bit dodgy on UNIX, but at least the UNIX paradigm is somewhat consistent - almost everything ends up being a file handle to a character or block device, and you can read or write to it.If I have to program C for pleasure, give me UNIX any day. If you are paying me to program, well that is somewhat different...

author: kjn4685
author_rank: Regular Contributor
timestamp: November 19, 2014, 05:30:16 am
content: Is there software to wright code and then simulate the code that I have written with out a broad.

author: dannyf
author_rank: Super Contributor
timestamp: November 19, 2014, 11:38:14 am
content: Yes and no, depending on what code you have written.

author: kjn4685
author_rank: Regular Contributor
timestamp: November 20, 2014, 11:14:12 pm
content: Like c

author: hamster_nz
author_rank: Super Contributor
timestamp: November 21, 2014, 01:14:05 am
content: AVRstudio has a simulator in it...

author: dannyf
author_rank: Super Contributor
timestamp: November 21, 2014, 11:46:42 am
content: QuoteYou may or may not debug like C, depending on the code you have written.