Saturday, February 20, 2010

Pic 16F913 Quick Reference Guide

I wrote a short Quick Reference guide for how I have been programming the Pic 16F913.
Check out the HOW TO here: Programming_The_Pic_16F913_QRG

Good luck and let me know how it goes.

Its should be pretty straight forward.

Wednesday, February 17, 2010

Emulator

Well I finally came up with a good project for my ECE 335 course,

I attempting to write an emulator for the Power PC 403 for the Microprocessors course ECE344, I was wishing the whole semester for the opportunity to have something to test on at home, so when I came into school to test on the actual boards I'd be able to know that my program would work as expected.

In keeping with ECE 335 I'm sure I'll write some "terrible" code without realizing it, at which point, I'll just go ahead and optimize it, this will have to be a really quick deal so initially I'm only going to support the addi command. Once that is up and working I'll reassess what is going to happen next.

The link to the project is here if you're interested in helping let me know.


Thursday, February 11, 2010

Counting

This is the VHDL for the counting algorithm from ECE 528 today.



Monday, February 8, 2010

Finding Bugs

So I was working with a buddy on a program he wrote in Assembly, he had nearly the whole thing complete, and before he's able to actually test it, he did one of the smartest things I can recommend if you can't actually test the code until some future date.

HE ASKED SOMEONE ELSE TO TAKE A SECOND LOOK.

Better then just asking someone else, asking someone else who has a better, even if it's slightly, knowledge of the subject, can see things that you might not see.

Now sure sitting in front of the computer with the board next to you and assembling, loading, running, then going back to debug can gain you some invaluable troubleshooting experience. I won't lie to you, learning how to attack a problem can be invaluable, but one of the biggest key's to do that follows.....

The key for the second person here, is to guide the programmer to the problem spot without giving away the answer if they know it.

Why so? By forcing the person to look at the code EXPECTING a problem they're going to start analyzing each and every line, Is it the right command here, did I set that up right, did I move this pointer to the right spot. EVERY LITTLE DETAIL should get scrutinized by the programmer. And that is good, they'll learn TONS and begin to see the big picture here.

Once you code something up, re-read it, re-read it again, now compare it to your design.

Wait a second I snuck something in there didn't I?

It comes back to design huh. IF every piece of the code you wrote can be traced back to a design element you wrote, you can break the problem, if there is one into a tiny piece, and that's a huge factor when you're working with 1k+ lines of code in assembly.

It might not seem to make sense working with a 50 line piece of code, but if you can force the habit it will make you a better programmer. I promise!

Sunday, February 7, 2010

The PIC 16F913

So I bought some PIC 16F913's I was hoping I could just literally plug in the PIC to the PicKit 1 and just program, turns out it's not that simple, but aside from hooking a couple wires up, well frankly it's not that hard. I just wired up the appropriate VSS, VPP, VDD, and ICSP Clock and Data lines.

One thing that threw me off, is that the microchip site said that the PicKit 1 programs the P16F913, this isn't "entirely true" I was able to use ICSP. Since I can't get MPLAB to program via ICSP, I was able to using the PicKit 1 Classic program, found on microchips website.


Here were my steps:
  1. Hooking up the ICSP. I actually tried to do a "read" with the PicKit 1 Classic S/W, it recognized that it was a 913 AWESOME, this is really good news.
  2. Load up a program into MPLAB and compile, turns out I was able to use the exact same "hello world" code from my 16F684, so I just compiled and was ready for the next step.
  3. I then pointed to the hex file compiled by MPLAB, from within the PicKit 1 Classic program.
  4. I just hooked up the appropriate pins to the LEDs on the board to make sure i was able to turn the LED on and off, if the S/W was working as I expected.
There you have it, it wasn't nearly as hard as I expected it to be, now that I can use the PIC16F913, well frankly I am pumped, the only thing I would really like to do is have a socket plug that I can use to directly wire up a ICSP port, then I can really just use a ICSP plug on any device/board and I "think" I can actually use it.

Next up is maybe serial communications? We'll see the sky's the limit now.