From: Martin Brown To: Subject: PIC and mix Date: 28 April 2004 08:07 Dear John, This is a quick note covering a selection of PIC related topics from recent (and not so recent) EPE Readout. But mainly to congratulate EPE on adding a new PIC n' Mix column in May for microcontroller development ideas. I was a bit surprised that you prefer crash and burn "real-time" testing of PIC code running directly on a PIC. I find the power of MPSIM (even the old DOS version) invaluable for quick development of new complex code that can be tested in isolation and with easy access to all variables. I might be interested in writing an article on using MPSIM if you think it would be of general interest. I built the delightful Icebreaker project a couple of years ago and that is another good stepping stone for prototyping. I would like to gain access to the C-code running at the PC end of the link to make a few small improvements to the user interface and add an extra P command to step over a function call. I would be happy to sign an NDA and return the modified code. It is for personal hobby use. I have recently been playing with direct drive LCD for a very low current continuous display. I wanted to make a sidereal rate clock for astronomy (which runs about 0.3% faster than mean solar time). This low power design uses a 32kHZ crystal, 16F877 driving an RS 0.6" 4 digit LCD display driven directly - drawing only 22uA total current on 3v. I doubt there is much call for sidereal clocks, but the LCD display design might still be of interest. It will run for a couple of years on two spent AA cells. It also has a novel digital fine adjustment by slightly altering the minute loop timing in 1ppm steps. Here is the computed GOTO that provides a mechanism for a handy variable cycle delay loop. Starting with the very simplest one - which is very space consuming for longer delays: ; Simple variable cycle delay loop for 8+W cycles where 0 < W < 8 in this example. DLY8_W ANDLW 7 ; mask W to match length of table XORLW 7 ; complement so that ; W=7 means 7 cycle extra delay ADDWF PCL,F ; computed goto NOP ; 7 NOP ; 6 NOP ; 5 NOP ; 4 NOP ; 3 NOP ; 2 NOP ; 1 RETURN ; Variable cycle delay loop for 17+W cycles by PCL arithmetic ; The computed jump must be located in the same page ; Tramples W, COUNT register DLY17_W MOVWF COUNT ; execute delay loop for 17+N cycles RRF COUNT,F RRF COUNT,F ; compute W/4 BCF COUNT,7 BCF COUNT,6 ; mask out top bits to zero 0