Fix PWM for fan

This commit is contained in:
Jeremy Soller 2019-11-06 15:34:03 -07:00
parent 330ccb5c47
commit 3d1e1aaae5
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
2 changed files with 9 additions and 11 deletions

View File

@ -7,21 +7,17 @@ void pwm_init(void) {
// Disable PWM
ZTIER = 0;
// Set prescaler to 1159 + 1
C6CPRS = 0x87;
C6MCPRS = 0x04;
// Set prescalar clock frequency to EC clock
PCFSR = 0b01;
// Set clock prescaler to 0 + 1
C0CPRS = 0;
// Set cycle time to 255 + 1
CTR2 = 0xFF;
CTR0 = 255;
// 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);
DCR2 = 128;
// Enable PWM
ZTIER = (1 << 1);

View File

@ -3,6 +3,8 @@
#include <stdint.h>
// Channel 0 clock prescaler register
volatile uint8_t __xdata __at(0x1800) C0CPRS;
// Channel 6 clock prescaler register (low byte)
volatile uint8_t __xdata __at(0x182B) C6CPRS;
// Channel 6 clock prescaler register (high byte)