//Timer 6 setup function int sysServiceConfigT6(unsigned int T6conval, unsigned int T6perval, unsigned int T6intconval){ //Todo: is there any way to have a compile time semaphore here? if(T6_already_confgured){ return -1; } else{ T6_already_confgured = 1; OpenTimer6(T6conval, T6perval); ConfigIntTimer6(T6intconval); return 0; } }
void setupTimer6(unsigned int fs) { unsigned int con_reg, period; con_reg = T6_ON & // Timer on T6_IDLE_STOP & // Stop timer when idle T6_GATE_OFF & // Gated mode off T6_PS_1_8 & // Prescale 1:8 T6_SOURCE_INT & // Internal clock source T6_32BIT_MODE_OFF; // 16 bit mode // period value = Fcy/(prescale*Ftimer) period = FCY/(8*fs); OpenTimer6(con_reg, period); ConfigIntTimer6(T6_INT_PRIOR_3 & T6_INT_ON); }
static void setupTimer6(void) { unsigned int con_reg; con_reg = T6_ON & // Enable module T6_IDLE_STOP & // Stop when idle T6_GATE_OFF & // Gate accumulator off T6_PS_1_64 & // 64:1 prescale T6_SOURCE_INT & // Internal source T6_32BIT_MODE_OFF; // Run 16-bit mode _T6IF = 0; WriteTimer6(0); OpenTimer6(con_reg, 0); ConfigIntTimer6(T6_INT_PRIOR_5 & T6_INT_OFF); }