Now I managed to open the file PWM2.c
//************************************************************************************
//**
//** Source name: C:\Users\maestro\Desktop\Flowcode Files\PWM2.fcfx
//** Title:
//** Description:
//** Device: ESP.ESP32.ESP32_WROOM_32
//**
//** Generated by: Flowcode v9.2.0.33
//** Date: Wednesday, March 16, 2022 12:49:07
//** Users: 1
//** Registered to: felixegger (38396505)
//** Licence key: JMA9BD
//**
//**
//** NOT FOR COMMERCIAL USE
//**
//**
https://www.flowcode.co.uk
//**
//************************************************************************************
#define MX_ESP
#define MX_CAL_ESP
#define MX_CLK_SPEED 240000000
#define FCP_NULL Unconnected_Port
#define MX_CAL_ESP32
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_wifi.h"
#include "esp_log.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "driver/adc.h"
#include "lwip/err.h"
#include "lwip/sys.h"
#include "sdkconfig.h"
/*========================================================================*\
Use :Include the type definitions
\*========================================================================*/
#include "C:\ProgramData\MatrixTSL\FlowcodeV9\CAL\internals.c"
MX_UINT8 FCLV_LOOP1;
MX_UINT8 FCLV_LOOP2;
/*========================================================================*\
Use :panel
:Variable declarations
:Macro function declarations
\*========================================================================*/
#define FCV_FALSE (0)
#define FCV_TRUE (1)
MX_GLOBAL MX_UINT8 FCV_AB;
MX_GLOBAL MX_UINT8 FCV_AA;
MX_GLOBAL MX_UINT8 FCV_BB;
MX_UINT8 FCM_ChangePeriod(MX_UINT16 FCL_PERIOD, MX_SINT16 FCL_PRESCALER);
MX_UINT8 FCM_SetDutyCycle(MX_UINT8 FCL_DUTY);
/*========================================================================*\
Use :cal_pwm
:Variable declarations
:Macro function declarations
\*========================================================================*/
#define MX_PWM_REF1
#define MX_PWM_PRESCALE1 (1)
#define MX_PWM_PIN_1 (4)
#define MX_PWM_TYPE_1 (0)
#define MX_PWM_PORT_1 PORTB
#define MX_PWM_TRIS_1 TRISB
#define MX_PWM_CHANNEL_1 (1)
/*=----------------------------------------------------------------------=*\
Use :cal_pwm
:Supplementary defines
\*=----------------------------------------------------------------------=*/
#define MX_PWM
#define MX_PWM_FREQ_1 1068
#define MX_PWM_REMAPPABLE
#define MX_PWM_RPOR_1 PPS0
#define MX_PWM_RPOC_1 1
#define MX_PWM_TMR_1 0
void FC_CAL_PWM_ChangePeriod_1(MX_UINT16 FCL_PERIOD, MX_UINT16 FCL_PRESCALER);
void FC_CAL_PWM_Disable_1();
void FC_CAL_PWM_SetDuty8Bit_1(MX_UINT8 FCL_DUTY);
void FC_CAL_PWM_Enable_1();
void FC_CAL_PWM_ChangeFrequency_1(MX_UINT32 FCL_FREQUENCY);
void FC_CAL_PWM_SetDuty10Bit_1(MX_UINT16 FCL_DUTY);
void FC_CAL_PWM_SetDutyFloat_1(MX_FLOAT FCL_DUTY);
/*========================================================================*\
Use :PWM1
:Variable declarations
:Macro function declarations
\*========================================================================*/
MX_GLOBAL MX_UINT8 FCV_0df41_PWM1__ENABLED = (0x0);
void FCD_0df41_PWM1__ChangePeriod(MX_UINT16 FCL_PERIOD, MX_SINT16 FCL_PRESCALER);
void FCD_0df41_PWM1__Disable();
void FCD_0df41_PWM1__SetDutyCycle(MX_UINT8 FCL_DUTY);
void FCD_0df41_PWM1__Enable();
void FCD_0df41_PWM1__SetFrequency(MX_UINT32 FCL_FREQUENCY);
void FCD_0df41_PWM1__SetDutyCycle10Bit(MX_UINT16 FCL_DUTY);
/*========================================================================*\
Use :Include the chip adaption layer
\*========================================================================*/
#include "C:\ProgramData\MatrixTSL\FlowcodeV9\CAL\includes.c"
/*========================================================================*\
Use :PWM1
:Macro implementations
\*========================================================================*/
/*=----------------------------------------------------------------------=*\
Use :Sets the overall period and prescaler of the output PWM signal.
:
:Parameters for macro ChangePeriod:
: Period : The maximum number that will represent 100% on, PIC/AVR: 0-255 16-bit PIC: 0-65535
: Prescaler : The scaler used to divide the system clock speed down to the PWM rate.
\*=----------------------------------------------------------------------=*/
void FCD_0df41_PWM1__ChangePeriod(MX_UINT16 FCL_PERIOD, MX_SINT16 FCL_PRESCALER)
{
FC_CAL_PWM_ChangePeriod_1(FCL_PERIOD, FCL_PRESCALER);
}
/*=----------------------------------------------------------------------=*\
Use :Disables a PWM channel and allows the default output / input state to be resumed
\*=----------------------------------------------------------------------=*/
void FCD_0df41_PWM1__Disable()
{
// Enabled = 0
FCV_0df41_PWM1__ENABLED = 0;
FC_CAL_PWM_Disable_1();
}
/*=----------------------------------------------------------------------=*\
Use :Sets the PWM duty cycle in terms of on/off based on the current period setting.
:E.g. if period = 255 then duty of 128 is equal to 50% on and 50% off.
:16-bit PIC users should use the 10bit duty function to access the full range.
:
:Parameters for macro SetDutyCycle:
: Duty : 8-bit PWM duty 0-255
\*=----------------------------------------------------------------------=*/
void FCD_0df41_PWM1__SetDutyCycle(MX_UINT8 FCL_DUTY)
{
#if 0 // Disabled code
if (FCV_0df41_PWM1__ENABLED)
{
// } else {
}
#endif // Disabled code
FC_CAL_PWM_SetDuty8Bit_1(FCL_DUTY);
}
/*=----------------------------------------------------------------------=*\
Use :Enables a PWM channel as an output overriding the default output pin state.
\*=----------------------------------------------------------------------=*/
void FCD_0df41_PWM1__Enable()
{
// Enabled = 1
FCV_0df41_PWM1__ENABLED = 1;
FC_CAL_PWM_ChangePeriod_1(90, 1);
FC_CAL_PWM_Enable_1();
}
/*=----------------------------------------------------------------------=*\
Use :Sets a PWM of the specifed frequency at a duty of 50%
:Ideal use is a frequency generator
:
:Parameters for macro SetFrequency:
: Frequency : Enter frequency in Hz
\*=----------------------------------------------------------------------=*/
void FCD_0df41_PWM1__SetFrequency(MX_UINT32 FCL_FREQUENCY)
{
//Local variable definitions
MX_UINT16 FCL_PERIODOVERFLOW;
MX_UINT8 FCL_PRESCALER;
MX_SINT16 FCL_DUTY10BIT;
// .Prescaler = 1
FCL_PRESCALER = 1;
while (1)
{
// .PeriodOverflow = (- .Prescaler + (ClockSpeed / (.Frequency << 2))) / .Prescaler
FCL_PERIODOVERFLOW = (-FCL_PRESCALER + (240000000 / (FCL_FREQUENCY << 2))) / FCL_PRESCALER;
if (FCL_PERIODOVERFLOW > 255)
{
// .Prescaler = .Prescaler << 2
FCL_PRESCALER = FCL_PRESCALER << 2;
// } else {
}
// .Duty10Bit = .PeriodOverflow << 1
FCL_DUTY10BIT = FCL_PERIODOVERFLOW << 1;
if (((FCL_PERIODOVERFLOW > 255) && (FCL_PRESCALER)) == 0) break;
}
FC_CAL_PWM_ChangePeriod_1(FCL_PERIODOVERFLOW, FCL_PRESCALER);
FC_CAL_PWM_SetDuty10Bit_1(FCL_DUTY10BIT);
}
/*=----------------------------------------------------------------------=*\
Use :PIC/AVR - Sets the full scale PWM duty cycle based on the current period setting.
:If period = 255 then Duty of 512 is equal to 50%.
:
:16-bit PICs have a 16-bit period range available.
:If period = 65535 then Duty of 32768 is equal to 50%.
:
:Parameters for macro SetDutyCycle10Bit:
: Duty : PWM duty PIC/AVR: 0-1023 16-bit PIC: 0-65535
\*=----------------------------------------------------------------------=*/
void FCD_0df41_PWM1__SetDutyCycle10Bit(MX_UINT16 FCL_DUTY)
{
#if 0 // Disabled code
if (FCV_0df41_PWM1__ENABLED)
{
// } else {
}
#endif // Disabled code
FC_CAL_PWM_SetDuty10Bit_1(FCL_DUTY);
}
/*========================================================================*\
Use :panel
:Macro implementations
\*========================================================================*/
/*=----------------------------------------------------------------------=*\
Use :Sets the overall period and prescaler of the output PWM signal.
:
:Parameters for macro ChangePeriod:
: Period : The maximum number that will represent 100% on, PIC/AVR: 0-255 16-bit PIC: 0-65535
: Prescaler : The scaler used to divide the system clock speed down to the PWM rate.
:
:Returns : MX_UINT8
\*=----------------------------------------------------------------------=*/
MX_UINT8 FCM_ChangePeriod(MX_UINT16 FCL_PERIOD, MX_SINT16 FCL_PRESCALER)
{
//Local variable definitions
MX_UINT8 FCR_RETVAL;
// Name: ChangePeriod, Type: Calculation:
// PWM1 :: ChangePeriod(.Period, .Prescaler)
FCD_0df41_PWM1__ChangePeriod(FCL_PERIOD, FCL_PRESCALER);
return (FCR_RETVAL);
}
/*=----------------------------------------------------------------------=*\
Use :Sets the PWM duty cycle in terms of on/off based on the current period setting.
:E.g. if period = 255 then duty of 128 is equal to 50% on and 50% off.
:16-bit PIC users should use the 10bit duty function to access the full range.
:
:Parameters for macro SetDutyCycle:
: Duty : 8-bit PWM duty 0-255
:
:Returns : MX_UINT8
\*=----------------------------------------------------------------------=*/
MX_UINT8 FCM_SetDutyCycle(MX_UINT8 FCL_DUTY)
{
//Local variable definitions
MX_UINT8 FCR_RETVAL;
// Name: SetDutyCycle, Type: Calculation:
// PWM1 :: SetDutyCycle(.Duty)
FCD_0df41_PWM1__SetDutyCycle(FCL_DUTY);
return (FCR_RETVAL);
}
/*========================================================================*\
Use :Main
\*========================================================================*/
void app_main()
{
// Initialize NVS
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
ESP_ERROR_CHECK(esp_event_loop_create_default());
// Name: Calculation, Type: Calculation:
// bb = 1
FCV_BB = 1;
// Name: Loop, Type: Loop: While 1
while (1)
{
//Comment:
// je grösser aa, desto kleiner PW
// bb, keinen Einfluss auf PW PW
// ab 280, ca 25%
// ab 300, ca 50%
// ab 330, ca 80%
// PINZUORDNUNG ??????????????
// Name: Calculation, Type: Calculation:
// aa = 90
// bb = 200
// ab = 280
FCV_AA = 90;
FCV_BB = 200;
FCV_AB = 280;
// Name: Delay, Type: Delay: 250 ms
FCI_DELAYBYTE_MS(250);
// Name: Component Macro, Type: Component Macro: PWM1::Enable()
FCD_0df41_PWM1__Enable();
// Name: Component Macro, Type: Component Macro: PWM1::SetDutyCycle(ab)
FCD_0df41_PWM1__SetDutyCycle(FCV_AB);
// Name: Delay, Type: Delay: 180 ms
FCI_DELAYBYTE_MS(180);
// Name: Component Macro, Type: Component Macro: PWM1::ChangePeriod(aa, bb)
FCD_0df41_PWM1__ChangePeriod(FCV_AA, FCV_BB);
// Name: Component Macro, Type: Component Macro: PWM1::Disable()
FCD_0df41_PWM1__Disable();
}
mainendloop: goto mainendloop;
}
/*========================================================================*\
Use :Interrupt
\*========================================================================*/
Thanks Felix