Hi All,
I try to find a simple example to Drive PC7 pin at 100khz with the TMR function in 16 bits mode (Unit 1).
i do that with the RPDG library but now i need to do the same thing without the library...
Regards
Yanick.
answer by my self...
setting is good but i missing the part of the Write-Protect Register (PWPR).. whitout that nothing works...
then this is the code in case other people need to know.
// ==== MPC Setting ====
PORTC.PDR.BIT.B7 = 0; // Select general input (defaut)
PORTC.PMR.BIT.B7 = 0; // Select General I/O (defaut)
MPC.PWPR.BIT.B0WI = 0; // 0: Writing to the PFSWE bit is enabled
MPC.PWPR.BIT.PFSWE = 1; // 1: Writing to the PFS register is enabled
MPC.PC7PFS.BYTE = 0x05; // set use PC7 as functin TMO2 Output
MPC.PWPR.BIT.PFSWE = 0; // 0: Writing to the PFS register is disabled
MPC.PWPR.BIT.B0WI = 1; // 1: Writing to the PFSWE bit is disabled
PORTC.PMR.BIT.B7 = 1; // 1 = function (ici choisi TMO2)
// ==== TMR module ON ====
SYSTEM.PRCR.WORD = 0x0A507; // protect off
MSTP(TMR23) = 0; // TMR23 module stop state is canceled
SYSTEM.PRCR.WORD = 0x0A500; // protect on
// ==== Load the registers ====
TMR23.TCNT = 0x0000; // Clear TCNT
TMR23.TCORA = 239; // compare match A sortie a 100Khz
TMR23.TCORB = 119; // compare match B sortie a 100Khz
TMR2.TCR.BYTE = 0x08; // Cleared by compare match A
TMR2.TCSR.BYTE = 0xC9; // Output Select B [1 0: High is output] , Output Select A [0 1: Low is output]
TMR3.TCSR.BYTE = 0xD0; // not used in 16 bits timer
TMR23.TCCR = 0x1808; // Counts at TMR1.TCNT (TMR3.TCNT) overflow signal , Counts at PCLK.
thanks all for your support.