// ### BOILERPLATE ### // Orthographic Cube Firmware // Copyright (C) 2006 Peter Todd // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // ### BOILERPLATE ### #include #include #include #include #pragma stack 0x700 255 code char at __CONFIG1H config1h = 0xFF & _OSC_HS_PLL_1H & _OSCS_OFF_1H; code char at __CONFIG2H config2l = 0xFF & _PUT_ON_2L & _BODEN_ON_2L & _BODENV_4_5V_2L; code char at __CONFIG2L config2h = 0xFF & _WDT_OFF_2H; //code char at __CONFIG4L config4l = 0xFF & _LVP_OFF_4L & _BACKBUG_OFF_4L; //code char at __CONFIG5H config5h = 0xFF; //code char at __CONFIG5L config5l = 0xFF; //code char at __CONFIG6H config6h = 0xFF; //code char at __CONFIG6L config6l = 0xFF; //code char at __CONFIG7H config7h = 0xFF; //code char at __CONFIG7L config7l = 0xFF; #include #include #include // Variables // Interupts, AKA signals. We have two types that we use, the TMR0 int, and the USART ints. DEF_INTHIGH(high_int) DEF_HANDLER(SIG_TMR0,_tmr0_handler) END_DEF SIGHANDLER(_tmr0_handler) { display_do_multiplex(); // reenable ourselves, by doing this last, we don't crash if the above takes too long to complete properly INTCONbits.T0IF = 0; } void main(){ static uint8_t x,y; // Ports TRISA = 0xFF; TRISB = 0; TRISC = 0; // turn all ADC ports off ADCON1 = 0x0F; #if 0 // setup pwm for brightness control // CCP1 is used PR2 = 0xFF; CCPR1L = 0x01; T2CON = 0; T2CONbits.TMR2ON = 1; T2CONbits.T2CKPS1 = 1; CCP1CON = 0x0C; // pwm mode #endif display_init(); cube_init(); // setup TMR0 for interrupts so the display multiplex code will run // 32,000,000/4=8,000,000/8/256=3906.25ints/sec // we want at least 35 lines * 90hz = 3150 ints/sec INTCONbits.T0IF = 0; INTCONbits.T0IE = 1; INTCONbits.GIE = 1; T0CON = 0xC3; // 55hz display updating, change to C2 to 110hz while (1){ // arot = arot - 0.1; // if (arot < (-2 * PI)) // arot = 0; // brot = ((-2 * PI) - brot); xrot++; yrot++; yrot++; // yrot++; display_clear(); render_cube(); switch_display_buffers(); delay10ktcy(15); } }