Milan94 je radio motalicu a ja sam pisao firmware za PIC18F4431.
Ako me dobro sećanje služi, hardver je realizovan slično kao kod tebe. Možda su drajveri drugi.
Neka me Milan94 ispravi ako negde grešim, ali mi smo potrebni PWM generisali sa 4 pina i dead time iz MCU. On je negde i pokazivao kako ta motalica radi.
Evo inicijalizacija PWM za PIC18F4431:
Treba da je to neka poslednja verzija mogu i da proverim...
Evo ovde je snimak:
https://www.youtube.com/watch?v=dPGYK2v52Eo
Sad ću da bacim pogled na ovaj tvoj PIC18F23k20
Ako me dobro sećanje služi, hardver je realizovan slično kao kod tebe. Možda su drajveri drugi.
Neka me Milan94 ispravi ako negde grešim, ali mi smo potrebni PWM generisali sa 4 pina i dead time iz MCU. On je negde i pokazivao kako ta motalica radi.
Evo inicijalizacija PWM za PIC18F4431:
Code:
void InitPCPWM(void)
{
OVDCOND = 0xFF; // Output on PWM I/O pin is controlled by the value in the Duty Cycle register and the PWM time base
OVDCONS = 0x00; // Output on PWM I/O pin is inactive when the corresponding PWM output override bit is cleared
// QEICON = 0x00; // QEI Disabled
PTCON1 = 0x00; // PWM time base is OFF and counts up.
PTCON0 = 0x00; // PWM time base PS=1:1, input clock is FOSC/4 and operates in a Free-Running mode
PWMCON0 = 0x30; // PWM0 - PWM3 I/O pins are enabled for PWM output in complementary mode
// PWMCON0 = 0x33; // PWM0 - PWM3 I/O pins are enabled for PWM output in independent mode
// PWMCON0 = 0x63; // PWM1, PWM3 pins enabled for PWM output in independent mode
// PWMCON0 = 0x11; // PWM1 I/O pin is enabled for PWM output in independent mode
// PWMCON0 = 0x20; // PWM0 and PWM1 pins are enabled for PWM output in complementary mode
PWMCON1 = 0x00; // Updates from Duty Cycle and Period Buffer registers are enabled
FLTCONFIG = 0b00000001; // FLTB disabled, FLTA enabled in Inactive mode (Pins are deactivated (catastrophic failure) until FLTA is deasserted)
// FLTCONFIG = 0b00000000; // FLTB disabled, FLTA enabled in Inactive mode (Pins are deactivated (catastrophic failure) until FLTA is deasserted)
SEVTCMPL = 0x00; // Clear special event compare value
SEVTCMPH = 0x00;
PDC0L = 0x00;
PDC0H = 0x00;
PDC1L = 0x00;
PDC1H = 0x00;
DTCON = 0x45; // 1us dead time, Clock source for Dead Time Unit is FOSC/4.
PTMRL = 0x00;
PTMRH = 0x00;
PTPERL = 0xFF; // 19.5KHz at 40MHz oscillator
PTPERH = 0x01;
}
Treba da je to neka poslednja verzija mogu i da proverim...
Evo ovde je snimak:
https://www.youtube.com/watch?v=dPGYK2v52Eo
Sad ću da bacim pogled na ovaj tvoj PIC18F23k20