Anobium - 2017-10-03

I have just completed a revision to the PWM support for Great Cow BASIC. Updated to support channels PWM1 to PWM9
.

You can enable fixed mode PWM for chips with PWM Modules (we already support CCP/PWM fixed mode) for PWM channels 1 thru 9 and you can select timer 2, 4 or 6.

Anyone want to test this new capability? You will need to have v0.98.00 as a mimimum.

Enjoy.

Anobium

Overview of Capability

You do not need to define all the timers and channels, just define the constants you need.

The minimum to get one channel operational are the following:
1. A timer with a frequency
2 .A PWM channel with a duty
3. A PWM channel clock source

The PWM_yy_Duty xx' where yy is between 1 and 9 and is a valid PWM module, and, xx is the Duty cycle for specific channels

The PMW_zz_Clock_Source tt. Where zz is channel and tt is the PWM clock source.

Example: For PWM channel 2 with a frequency of 38Khz with a duty of 50% with a clock source of timer 2, use

#define PWM_Timer2_Freq 38
#define PWM_7_Duty 50
#define PMW_7_Clock_Source 2

The complete set of constants, with some examples, is shown below:

#define PWM_Timer2_Freq 38        'Set frequency in KHz, just change the number
#define PWM_Timer4_Freq 31        'Set frequency in KHz, just change the number
#define PWM_Timer6_Freq 65        'Set frequency in KHz, just change the number

#define PWM_1_Duty 10            'Set duty cycle as percentage 0-100%, just change the number
#define PMW_1_Clock_Source 4

#define PWM_2_Duty 25
#define PMW_2_Clock_Source 6

#define PWM_3_Duty 50
#define PMW_3_Clock_Source 6

#define PWM_4_Duty 50
#define PMW_4_Clock_Source 4

#define PWM_5_Duty 50
#define PMW_5_Clock_Source 2

#define PWM_6_Duty 45
#define PMW_6_Clock_Source 4

#define PWM_7_Duty 50
#define PMW_7_Clock_Source 2

#define PWM_8_Duty 75
#define PMW_8_Clock_Source 2

#define PWM_9_Duty 25
#define PMW_9_Clock_Source 2
 

Last edit: Anobium 2017-10-04