Hier was für T2, T3. Vielleicht gibt's dir ja ne Idee, wie es mit T5, T6 geht...
Code:
void timebase_setup (unsigned int ticks)
{
unsigned int prescale = 8;
unsigned long reload;
reload = (unsigned long) 65536 - F_CPU / (prescale * ticks);
#if defined (__XC16X__)
GPT12E_T3CON = 0x0000; /* Timermode, count up */
GPT12E_T2CON = 0x0027; /* Reloadmode for T3, count up, stop */
GPT12E_T2 = (unsigned int) reload; /* Reload for T3 */
GPT12E_T3IC = 0x40 | ((2 << 2) | 0); /* Int Level 2, group 0, enabled */
SET_SFRBIT(T3R); /* Timer 3 run */
#elif defined(C165)
T3CON = 0x0000; /* Timermode, count up, stop */
T2CON = 0x0027; /* Reloadmode for T3, count up, stop */
T2 = (unsigned int) reload; /* Reload for T3 */
T3IC = 0x40 | ((2 << 2) | 0); /* Int Level 2, group 0, enabled */
SET_SFRBIT(T3R); /* Timer 3 run */
#else
T0REL = (unsigned int) reload;
T0 = (unsigned int) reload;
T0IC = 0x40 | ((2 << 2) | 0); /* Int Level 2, group 0, enabled */
SET_SFRBIT(T0R);
#endif
}
Lesezeichen