Thursday, July 28, 2011

Driving, Interrupted

Today I want to work on the interrupt-handling subsystem (reentr.{c,h}, interrupt.{c.h}), while David hopefully writes most of the driver code for the input-capture datapath.

I need to define some data structures for him to work with, and outline his main functions for him.

Also, I decided to merge the icdp_stat and icdp_ctrl registers into a single bidirectional icdp_ctrl register - it will simplify things not to have any more registers than necessary.  The SOPC builder design and the top-level schematic will need to be changed as well.

We are having a group meeting with Ray at about 4:00 pm.

OK, I wrote reentr.{c,h}, but it still needs to be tested.

The new register format for the icdp_ctrl PIO (with both control & status bits) will now be:
  • Bit #0:  RUN_PAUSEn (output only) - 1 to run, 0 to pause datapath.  Currently unused (DP always runs).
  • Bit #1:  PUMP_DATA (output only) - 1 to pull next word, 0 to relax. 
  • Bit #2:  BUF_FULL (input only, interrupt) - 1 when DP is stalled b/c FIFO is full; 0 otherwise.
  • Bit #3:  HAVE_DATA (input only, interrupt) - 1 where there's data waiting to be read; 0 otherwise.
I updated the SOPC design and am regenerating the Nios system.

Hooked up the CPU in the top-level schematic, and made a new version of the top-level schematic (top7) that removes all of the now-unused test stub modules and cleans up the format a bit.  Recompiling the new schematic with the CPU in place.

Fitter is slow!  At some point, I should perhaps switch it back to Standard mode, and see if it is still fast enough at that speed. 

Now recompiling the firmware, to rebuild the system libraries for the new icdp_ctrl PIO, and test-compile the new reent.c module.

Hum, had a weird problem again where the compilation environment forgot how to build stuff.  I think that both of the times this happened recently, it was because I had just done a "make clean."  Note to self:  Don't do a make clean.  Anyway, created a new software_v3 folder as a workaround.  Whoops, same problem there?  Aha, the problem was my "for reference" folder where I put the GPS main.  Renamed it to for_reference and removed it from the (v2) project.

David wasn't able to open the workspace while I was working in it, so I created another copy called software_david for him to work in.  Later, Darryl can create one named software_darryl, and I will rename mine to software_mpf when I can.  We'll have to manually copy changed source files back and forth between them as needed, but at least we'll all be able to see each other's code.

I wrote the icdp_driver.h file defining the interface to the icdp_driver module, and David and Darryl are working together on writing the implementation (.c file).

We had our group meeting reviewing the project status.  Tyler wasn't able to make it, but David and Darryl and I (and Ray) were there.  Ray says we should do a test with the pocket pulser soon, and plan to test with the real PMTs after Aug. 15th.  There will be a group dinner next Thursday.

David and Darryl are making progress on the icdp_driver.c module.  Meanwhile, I wrote interrupt.{h,c} and am test-compiling them; they have not yet been test.  That will probably have to wait until the ICDP driver is finished (since we will not be able to get repeated interrupt events until the driver is consuming the input data).

OK, interrupt.c compiles cleanly now... Next the students need to finish up icdp_driver.c so that it can be linked in and we can run a test.

David, Darryl, a suggestion:  If you are having trouble putting together the driver code in your head, then break down the problem into smaller, bite-sized pieces: i.e., use modular design.  For example, here is a good helper function you should implement:

unsigned int get_next_word(void);


This should do everything necessary to pump out the next word of data from the device, and return it.  Then you can use this function as many times as you need in the code, without repeating the work of writing it each time.


You can do it.  It's really not difficult at all...

No comments:

Post a Comment