Fix PWM for fan
This commit is contained in:
		@@ -7,21 +7,17 @@ void pwm_init(void) {
 | 
				
			|||||||
    // Disable PWM
 | 
					    // Disable PWM
 | 
				
			||||||
    ZTIER = 0;
 | 
					    ZTIER = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Set prescaler to 1159 + 1
 | 
					    // Set prescalar clock frequency to EC clock
 | 
				
			||||||
    C6CPRS = 0x87;
 | 
					    PCFSR = 0b01;
 | 
				
			||||||
    C6MCPRS = 0x04;
 | 
					
 | 
				
			||||||
 | 
					    // Set clock prescaler to 0 + 1
 | 
				
			||||||
 | 
					    C0CPRS = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Set cycle time to 255 + 1
 | 
					    // Set cycle time to 255 + 1
 | 
				
			||||||
    CTR2 = 0xFF;
 | 
					    CTR0 = 255;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Turn on the CPU fan at half blast (temperature control TODO)
 | 
					    // Turn on the CPU fan at half blast (temperature control TODO)
 | 
				
			||||||
    DCR2 = 0x80;
 | 
					    DCR2 = 128;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Set gating clock source
 | 
					 | 
				
			||||||
    PCSGR = 0xFF;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Set PWM2 output to use C6CPRS / CTR2
 | 
					 | 
				
			||||||
    PCSSGL = (0b10 << 4);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Enable PWM
 | 
					    // Enable PWM
 | 
				
			||||||
    ZTIER = (1 << 1);
 | 
					    ZTIER = (1 << 1);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Channel 0 clock prescaler register
 | 
				
			||||||
 | 
					volatile uint8_t __xdata __at(0x1800) C0CPRS;
 | 
				
			||||||
// Channel 6 clock prescaler register (low byte)
 | 
					// Channel 6 clock prescaler register (low byte)
 | 
				
			||||||
volatile uint8_t __xdata __at(0x182B) C6CPRS;
 | 
					volatile uint8_t __xdata __at(0x182B) C6CPRS;
 | 
				
			||||||
// Channel 6 clock prescaler register (high byte)
 | 
					// Channel 6 clock prescaler register (high byte)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user