Jim's
Tutorials

Spring 2012
course
navigation

02-19-12

One of the things I've learned today (and a little bit yesterday) is that it is remarkably difficult to get even simple example programs working on these small chips. Perhaps I had been looking in the wrong places with the wrong search terms.
After trying a great number of versions of different code that would get the chip to accept a switch as an input, I finally stumbled across this one, in the "reading an input" section. It's written for a different environment with a different programmer but the code example I tried worked the first time without a hitch.
I spent a decent chunk of time staring at the datasheet, in particular, section 10.2. I was told by Alex that it's essential to pull up the index side-bar for your PDF viewer, otherwise the 234 page document is completely unmanageable. I like how well everything is organized.
from 10.2, here are some of the main points I gleaned:

I think it was the combination of not knowing exactly which resistors to use and imprecise google search terms that lead to the extreme difficulty I've experienced in getting this simple example to work.
I think my next step will be to get analog inputs and outputs working. From there,

in class

Aaron asked about how to spread out C code between several files.
Here's an example. Three files: demo.c, jims_lib.c, jims_lib.h
/* demo.c */ #include <stdio.h> #include "jims_lib.h" int main(){ int y = 7; printf(" y=%i, f(y)=%i \n", y, double_it_add_one(y)); }
/* jims_lib.c */ #include "jims_lib.h" int double_it_add_one(int x){ return ONE + 2*x; }
/* jims_lib.h */ #define ONE 1 int double_it_add_one(int x);
Then to compile and run 'em:
$ cc jims_lib.c demo.c -o demo # compile both of 'em $ ./demo # run it.
Jim says:
Please add C code for this week, and circuit diagram.
http://cs.marlboro.edu/ courses/ spring2012/jims_tutorials/ aaron/ 02-19-12
last modified Monday February 20 2012 11:03 am EST

attachments [paper clip]

     name last modified size
[IMG]aaron.jpeg Feb 20 2012 11:02 am 2.81MB [VID]aaron.mov Feb 20 2012 11:02 am 38.4MB