PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Hilfe bei PWM mit PIC32MK...



Bumbum
03.05.2022, 14:37
Hallo,

ich arbeite mich gerade in die PIC Controller ein. Ich hänge gerade beim erzeugen eines PWM-Signals. Ich möchte damit einfach eine LED dimmen, die über einen Transistor am Ausgang hängt. Folgendes habe ich konfiguriert:

35784

Und hier ist mein Code:



int main ( void )
{
/* Initialize all modules */
SYS_Initialize ( NULL );

MCPWM_Initialize ();
MCPWM_ChannelPrimaryDutySet (0, 50);
MCPWM_ChannelPrimaryDutySet (1, 50);
MCPWM_Start ();

while ( true )
{
/* Maintain state machines of all polled MPLAB Harmony modules. */
SYS_Tasks ( );
}

/* Execution should not come here during normal operation */

return ( EXIT_FAILURE );
}


Der Pin bleibt aber auf Low. Kann mir jemand einen Tipp geben, was noch fehlt?

Viele Grüße
Andreas

Bumbum
04.05.2022, 09:09
Hallo,

ich habe die Ursache gefunden. Die Reihenfolge machts. So funktioniert es:



int main ( void )
{
/* Initialize all modules */
SYS_Initialize ( NULL );

MCPWM_Start ();
MCPWM_ChannelPrimaryDutySet (MCPWM_CH_1, 50);

while ( true )
{
/* Maintain state machines of all polled MPLAB Harmony modules. */
SYS_Tasks ( );
}

/* Execution should not come here during normal operation */

return ( EXIT_FAILURE );
}


Viele Grüße
Andreas