Attempt to initialize PWM for CPU fan

This commit is contained in:
Jeremy Soller 2019-10-01 12:01:46 -06:00
parent 2fc173faa3
commit a300a5681a
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1

View File

@ -3,6 +3,26 @@
void pwm_init(void) {
// Set T0CHSEL to TACH0A and T1CHSEL to TACH1A
TSWCTLR = 0;
// Turn on the CPU fan at full blast (temperature control TODO)
DCR2 = 0xFF;
// Disable PWM
ZTIER = 0;
// Set prescaler to 1159 + 1
C6CPRS = 0x87;
C6MCPRS = 0x04;
// Set cycle time to 255 + 1
CTR2 = 0xFF;
// Turn on the CPU fan at half blast (temperature control TODO)
DCR2 = 0x80;
// Set gating clock source
PCSGR = 0xFF;
// Set PWM2 output to use C6CPRS / CTR2
PCSSGL = (0b10 << 4);
// Enable PWM
ZTIER = (1 << 1);
}