Might work...
authorMalte S. Stretz <mss@apache.org>
Fri, 9 Jan 2009 10:39:24 +0000 (10:39 +0000)
committerMalte S. Stretz <mss@apache.org>
Fri, 9 Jan 2009 10:39:24 +0000 (10:39 +0000)
src/buffer.c
src/dmxpainter.aps
src/main.c
src/mcu_atmega8.h
src/tlc.c
src/tlc.h

index dacc8c3..3de57cb 100644 (file)
@@ -60,7 +60,7 @@ sched_res_t buffer_test_next(void)
     if (rgb == 0) cnt *= -1;\r
   }\r
 \r
-  tlc_start();\r
+  tlc_set_data_done();\r
 #endif\r
   return SCHED_RE;\r
 }\r
index b546de2..8fc0147 100644 (file)
@@ -1 +1 @@
-<AVRStudio><MANAGEMENT><ProjectName>dmxpainter</ProjectName><Created>24-Oct-2008 15:37:50</Created><LastEdit>06-Jan-2009 16:56:16</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>24-Oct-2008 15:37:50</Created><Version>4</Version><Build>4, 13, 0, 528</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>dmxpainter.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\dmxpainter\src\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATmega8.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0><Variables>gs_buffer</Variables><Variables>temp</Variables><Variables>dc_buffer</Variables><Variables>func</Variables></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><modules><module></module></modules><Triggers><trigger clsid="{113824F1-C410-4699-A25E-867CC860C28E}" enabled="1" boundTo="0" hitCount="1" updateAndContinue="0" line="39" file="tlc.c" token="  pin_on(PIN_TLC_BLNK);" offset="0"/><trigger clsid="{113824F1-C410-4699-A25E-867CC860C28E}" enabled="1" boundTo="0" hitCount="1" updateAndContinue="0" line="75" file="tlc.c" token="  pin_out_off(PIN_TLC_GSCK);" offset="0"/></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>main.c</SOURCEFILE><SOURCEFILE>sd.c</SOURCEFILE><SOURCEFILE>tlc.c</SOURCEFILE><SOURCEFILE>buffer.c</SOURCEFILE><SOURCEFILE>dmx.c</SOURCEFILE><SOURCEFILE>sched.c</SOURCEFILE><HEADERFILE>bits.h</HEADERFILE><HEADERFILE>sd.h</HEADERFILE><HEADERFILE>pins.h</HEADERFILE><HEADERFILE>config.h</HEADERFILE><HEADERFILE>tlc.h</HEADERFILE><HEADERFILE>buffer.h</HEADERFILE><HEADERFILE>dmx.h</HEADERFILE><HEADERFILE>mcu.h</HEADERFILE><HEADERFILE>mcu_atmega8.h</HEADERFILE><HEADERFILE>pins_atmega8.h</HEADERFILE><HEADERFILE>sched.h</HEADERFILE><OTHERFILE>Makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>Makefile</EXTERNALMAKEFILE><PART>atmega8</PART><HEX>1</HEX><LIST>0</LIST><MAP>0</MAP><OUTPUTFILENAME>dmxpainter.elf</OUTPUTFILENAME><OUTPUTDIR>bin\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS><OPTION><FILE>buffer.c</FILE><OPTIONLIST></OPTIONLIST></OPTION><OPTION><FILE>main.c</FILE><OPTIONLIST></OPTIONLIST></OPTION><OPTION><FILE>sd.c</FILE><OPTIONLIST></OPTIONLIST></OPTION><OPTION><FILE>tlc.c</FILE><OPTIONLIST></OPTIONLIST></OPTION><OPTION><FILE>tlc_isr.c</FILE><OPTIONLIST></OPTIONLIST></OPTION></OPTIONS><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2     -std=c99      -DF_CPU=16000000UL -O1 -fsigned-char</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20080610\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20080610\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="1" orderaddress="1" ordergroup="1"/></IOView><Files><File00000><FileId>00000</FileId><FileName>main.c</FileName><Status>259</Status></File00000><File00001><FileId>00001</FileId><FileName>tlc.c</FileName><Status>259</Status></File00001><File00002><FileId>00002</FileId><FileName>sched.c</FileName><Status>258</Status></File00002><File00003><FileId>00003</FileId><FileName>dmx.c</FileName><Status>257</Status></File00003><File00004><FileId>00004</FileId><FileName>pins.h</FileName><Status>1</Status></File00004><File00005><FileId>00005</FileId><FileName>Makefile</FileName><Status>1</Status></File00005></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>\r
+<AVRStudio><MANAGEMENT><ProjectName>dmxpainter</ProjectName><Created>24-Oct-2008 15:37:50</Created><LastEdit>06-Jan-2009 18:53:00</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>24-Oct-2008 15:37:50</Created><Version>4</Version><Build>4, 13, 0, 528</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>dmxpainter.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\dmxpainter\src\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATmega8.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0><Variables>gs_buffer</Variables><Variables>temp</Variables><Variables>dc_buffer</Variables><Variables>func</Variables></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><modules><module></module></modules><Triggers><trigger clsid="{113824F1-C410-4699-A25E-867CC860C28E}" enabled="1" boundTo="0" hitCount="1" updateAndContinue="0" line="39" file="tlc.c" token="  pin_on(PIN_TLC_BLNK);" offset="0"/><trigger clsid="{113824F1-C410-4699-A25E-867CC860C28E}" enabled="1" boundTo="0" hitCount="1" updateAndContinue="0" line="78" file="tlc.c" token="  pin_out_off(PIN_TLC_GSCK);" offset="0"/></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>main.c</SOURCEFILE><SOURCEFILE>sd.c</SOURCEFILE><SOURCEFILE>tlc.c</SOURCEFILE><SOURCEFILE>buffer.c</SOURCEFILE><SOURCEFILE>dmx.c</SOURCEFILE><SOURCEFILE>sched.c</SOURCEFILE><HEADERFILE>bits.h</HEADERFILE><HEADERFILE>sd.h</HEADERFILE><HEADERFILE>pins.h</HEADERFILE><HEADERFILE>config.h</HEADERFILE><HEADERFILE>tlc.h</HEADERFILE><HEADERFILE>buffer.h</HEADERFILE><HEADERFILE>dmx.h</HEADERFILE><HEADERFILE>mcu.h</HEADERFILE><HEADERFILE>mcu_atmega8.h</HEADERFILE><HEADERFILE>pins_atmega8.h</HEADERFILE><HEADERFILE>sched.h</HEADERFILE><OTHERFILE>Makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>Makefile</EXTERNALMAKEFILE><PART>atmega8</PART><HEX>1</HEX><LIST>0</LIST><MAP>0</MAP><OUTPUTFILENAME>dmxpainter.elf</OUTPUTFILENAME><OUTPUTDIR>bin\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS><OPTION><FILE>buffer.c</FILE><OPTIONLIST></OPTIONLIST></OPTION><OPTION><FILE>main.c</FILE><OPTIONLIST></OPTIONLIST></OPTION><OPTION><FILE>sd.c</FILE><OPTIONLIST></OPTIONLIST></OPTION><OPTION><FILE>tlc.c</FILE><OPTIONLIST></OPTIONLIST></OPTION><OPTION><FILE>tlc_isr.c</FILE><OPTIONLIST></OPTIONLIST></OPTION></OPTIONS><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2     -std=c99      -DF_CPU=16000000UL -O1 -fsigned-char</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20080610\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20080610\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>main.c</FileName><Status>259</Status></File00000><File00001><FileId>00001</FileId><FileName>tlc.c</FileName><Status>259</Status></File00001><File00002><FileId>00002</FileId><FileName>sched.c</FileName><Status>258</Status></File00002><File00003><FileId>00003</FileId><FileName>dmx.c</FileName><Status>257</Status></File00003><File00004><FileId>00004</FileId><FileName>pins.h</FileName><Status>1</Status></File00004><File00005><FileId>00005</FileId><FileName>mcu_atmega8.h</FileName><Status>1</Status></File00005><File00006><FileId>00006</FileId><FileName>buffer.c</FileName><Status>1</Status></File00006><File00007><FileId>00007</FileId><FileName>config.h</FileName><Status>1</Status></File00007><File00008><FileId>00008</FileId><FileName>tlc.h</FileName><Status>1</Status></File00008><File00009><FileId>00009</FileId><FileName>bits.h</FileName><Status>1</Status></File00009></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>\r
index 355670c..979d3f9 100644 (file)
@@ -25,6 +25,7 @@
 //////////////////////////////////////////\r
 // Interrupts\r
 \r
+#if 0\r
 // INT0:  External int, DMX sync\r
 ISR(INT0_vect)\r
 {\r
@@ -36,20 +37,20 @@ ISR(TIMER0_OVF_vect)
 {\r
 //  dmx_count_frame();\r
 }\r
-\r
-\r
+#endif\r
 \r
 \r
 // TIMER1: 16-Bit: GSCLK\r
 ISR(TIMER1_COMPA_vect)\r
 {\r
-  //tlc_start_gscycle_timeout();\r
+  tlc_start_gscycle_timeout();\r
 }\r
 \r
 \r
 \r
 \r
 // TIMER2:  8-Bit: GS-Refresh-Timer\r
+uint8_t g_t2_comp;\r
 ISR(TIMER2_COMP_vect)\r
 {\r
   tlc_stop_gscycle();\r
@@ -68,14 +69,14 @@ int main(void)
   sched_init();\r
 \r
   // Initialize peripherals.\r
-  dmx_init();\r
+  //dmx_init();\r
   tlc_init();\r
 \r
   sei();\r
   // Start DMX\r
   //dmx_start();\r
   // not done yet, use dummy data\r
-  tlc_start();\r
+  tlc_set_data_done();\r
 \r
   // Start scheduler.\r
   sched_loop();\r
index b184ff8..61b1e00 100644 (file)
@@ -19,8 +19,8 @@
 #define mcu_pin_timer1_ocmb_enable()  pin_out(PIN_OC1B)
 #define mcu_pin_timer1_ocmb_disable() pin_in( PIN_OC1B)
 
-#define mcu_set_timer2_cnt(v)  TCNT2 = v
-#define mcu_set_timer2_ic(v)   ICR2  = v
+#define mcu_set_timer2_cnt(v)  TCNT2 = v\r
+#define mcu_set_timer2_ocm(v)  OCR2  = v
 #define mcu_int_timer2_ocm_enable()   _BS(TIMSK, _BV(OCIE2));
 #define mcu_int_timer2_ocm_disable()  _BC(TIMSK, _BV(OCIE2));
 #define mcu_pin_timer2_ocm_enable()   pin_out(PIN_OC2)
index fbc4256..64d1b1e 100644 (file)
--- a/src/tlc.c
+++ b/src/tlc.c
@@ -71,19 +71,15 @@ sched_res_t wait_for_data(void)
 \r
 void tlc_init(void)\r
 {\r
-  // Initialize blanked (ie. LEDs off).\r
-  //set_blnk_on();\r
-\r
   // All these pins write to the painter.\r
   pin_out_off(PIN_TLC_GSCK);\r
   pin_out_off(PIN_TLC_VPRG);\r
   pin_out_off(PIN_TLC_XLAT);\r
   pin_out_off(PIN_TLC_SCLK);\r
   pin_out_off(PIN_TLC_SIN);\r
-  pin_out_off(PIN_TLC_BLNK);\r
 \r
   // Initialize blanked (ie. LEDs off).\r
-  set_blnk_on();\r
+  pin_out_on(PIN_TLC_BLNK);\r
 \r
   // Timer 1 is for our GSCLK:  We refresh with a GS cycle of\r
   // about 100 Hz (cf. Timer 2), for each full cycle we need to\r
@@ -92,8 +88,8 @@ void tlc_init(void)
   mcu_pin_timer1_ocma_disable();\r
   // Shortest duty cycle possible.\r
   mcu_set_timer1_ocma(1);\r
-  // We need about 39 clocks to get 4096 cycles at 100 Hz.\r
-  mcu_set_timer1_ic(39);\r
+  // We need about 38 clocks to get 4096 cycles at 100 Hz.\r
+  mcu_set_timer1_ic(38);\r
   // * CS1 = 0001:  No prescaler. (p100)\r
   // * WGM1 = 1110: Fast PWM, TOP at ICR1\r
   // * COM1A = 10: Set at 0, clear at Output Compare Match)\r
@@ -107,13 +103,13 @@ void tlc_init(void)
   // * Prescaler: 1024 (CS22:0 = 111) => 15625 Hz\r
   TCCR2 = _BV(CS22) | _BV(CS21) | _BV(CS20);\r
   // To get a 100 Hz clock we need to count 157 times (~ 99.5 Hz).\r
-  mcu_set_timer1_ic(156);\r
+  mcu_set_timer2_ocm(156);\r
 \r
   // Wait for first DMX packet.\r
   sched_put(&wait_for_data);\r
 }\r
 \r
-void tlc_start(void)\r
+void tlc_set_data_done(void)\r
 {\r
   g_data_done = 1;\r
 }\r
@@ -124,7 +120,6 @@ void tlc_start_gscycle(void)
 {\r
   // Start counter with next GS pulse.\r
   mcu_int_timer1_ocma_enable();\r
-  set_blnk_on();\r
 }\r
 \r
 void tlc_start_gscycle_timeout(void)\r
@@ -137,11 +132,10 @@ void tlc_start_gscycle_timeout(void)
 \r
   // Restart and enable timeout timer.\r
   mcu_set_timer2_cnt(0);\r
-  //mcu_int_timer2_ocm_enable();\r
+  mcu_int_timer2_ocm_enable();\r
 \r
   // Switch off BLNK.\r
-  //set_blnk_off();\r
-  set_blnk_on();\r
+  set_blnk_off();\r
 }\r
 \r
 void tlc_stop_gscycle(void)\r
index a000021..88ed774 100644 (file)
--- a/src/tlc.h
+++ b/src/tlc.h
@@ -9,10 +9,9 @@
 #define N_TLC_CHANNELS (N_RGB_CHANNELS * 3)\r
 \r
 void tlc_init(void);\r
-void tlc_start(void);\r
+//void tlc_start(void);\r
 \r
-void tlc_update(void);\r
-int  tlc_busy(void);\r
+void tlc_set_data_done(void);\r
 \r
 void tlc_start_gscycle(void);\r
 void tlc_start_gscycle_timeout(void);\r