RS232 on a PIC - finally some results08 Feb 2009
This past week, I've tried to get RS232 communication working between my PC and 16F627 PIC over a serial cable. And finally succeeded today.
Here are a couple lessons I've learned:
Windows is a piece of turd - getting the PIC programmer working in Linux
I've said it before, but I can't repeat it enough: Windows is crap. One could say that
the development platform created by Microchip is probably the best to do PIC programming, but it's not. I've been using GPSim to do my simulations and codetesting under linux and it works fantastically.
I would have used Linux for the entire development and testing, but my PIC programmer (Velleman K8048) seemed unsupported in Linux. Everytime I had some working code, I had to reboot to Windows just so I could burn the code on a PIC. That's just stupid.
Luckily I've found a way to program the PIC from Linux.
Moving an IC between programmer and breadboard all the time comes at a cost - ICSP
Moving the PIC between programmer and breadboard all the time has an unforeseen side-effect: after a while pins start being bent and break off. I've lost 3 already.
Instead of moving the PIC around all the time I figured it would be better to use ICSP. So I created a cable for it and tried it out: no joy.
I don't know why it doesn't work, more research and testing is needed.
When the oscilloscope is showing some weird Klingonlike signal, something is wrong with it
Meaning when it looks like this:
I found out that the cable of the scope is damaged or broken in some way. After replacing it, the signal looked OK.
Simulation environments differ from the real world
GPSim runs with a 20MHz clock while the internal oscillator of my PIC runs at 4Mhz. Blindly uploading the same code to the PIC will therefor not work. It needs to be modified to take that lover speed in to account.