I got the timing right, so the fan is spinning correctly now and the power supply doesn't go nuts anymore.
BUT it doesn't start spinning on its own now.
I tried to write a simple code to give it a nod in the right direction, but if I do this, everything stops working.
void main()
{
ANSEL = 0x00; // Set ports as digital I/O, not analog input
ADCON0 = 0x00; // Shut off the A/D Converter
CMCON = 0x07; // Shut off the Comparator
VRCON = 0x00; // Shut off the Voltage Reference
TRISIO = 0x08; // GP3 input, rest all output
GPIO = 0x00; // Make all pins 0
InitPWM(); // Initialize PWM
PWM = 180; // 50% duty cycle
while(1)
{
}
}
This is the main.c , if I put a function like "void start(void)" with some code after that, it only does that and nothing else. I tried return at the end, but to no avail.
I searched some stuff on google of course, but it's hard for me to differentiate between C and C++ and even if it is C, some things just don't work. I think it's because of the rather old HI-Tech compiler I'm using.