Experiment 7 AUTOSAR PWM breathing light and

table of Contents

First, the purpose of the experiment 

Second, the experimental environment

Third, the experimental procedures

Four, Port Configuration

Five, MCU configuration

Six, PWM configuration

Seven, the main program

Eight function parameter analysis

====================================================================

First, the purpose of the experiment 

(1) be familiar with pwm and port configuration parameters, the actual operation to identify problems reading the document did not pay attention

(2) adjust the light brightness pwm

Second, the experimental environment

Window10

Server: windows

And server interaction software winscp putty

AUTOSAR Version: 4.2.2

Tresos studio 23.0

MCAL Version: S32K14X_MCAL4_2_RTM_HF8_1_0_1

Compiling environment:greenhill 201714

Debugging environment: ic5000

 

Third, the experimental procedures

1. Modify MCAL configuration by EB, and onboard RGB lights arranged pwm

2. Verify configured to generate an output file in the output of EB

MCAL MCAL project file 3. Copy the template project file replacement project

4. Perform batch file copy the template project file

5. By uploading engineering winscp

6. compile command putty

7. Compile a nice project to the local download

8. By ic5000 download debugging

 

9. The module related to: port module, mcu modules (FTM clock), pwm module

10. involved interrupt uses FTM interrupt, the interrupt in the configuration PwmHwConfiguration in. No need to set the loHwAB.c in.

Four, Port Configuration

port before the port has been configured, but here to telling about the configuration naming. Naming configuration may be divided by function, may be divided in accordance with the order of the pin, respectively, is also designated function name and pin number. Which naming it better?

According to the function name looks more intuitive, easier to find, but PortPin Id is allocated sequentially, is not conducive to modify later;

According to pin order named, to be used and unused pins are assigned, so late to modify the workload is reduced, but need to find the corresponding function according to the pin, of course, can add functionality behind the name, that would be too long.

Overall, this configuration is not very like pwm using its name after completion, with pin names will be more convenient, if it is required to use GPIO like its name, the function will be more convenient for each pin operation.

Five, MCU configuration

Six, PWM configuration

PWM configuration into PwmChannel, PwmFtmModule, PwmHwConfiguration three parts.

PwmChannel Configuration

1. The configuration of a path is the path PwmFtmModule

2. whether to allow changes in pwm cycle, changes in the main program cycle, then this should be set to the appropriate mode, or an error occurs

3. Set the start of a pwm duty cycle of the polarity of the polarity ---

4. Set the pwm duty cycle, the resolution is fixed, as 0x8000 (32768), a set value needs to be within this range 0-0x8000. Here the initial value is set.

The setting of the reference clock pwm

1. Select the hardware unit

2. prescaler   to clock input ftm dividing the frequency after the frequency division to obtain a tick, in accordance with the number of tick pwm cycle period * tick size can be obtained

PwmFtmchannels Configuration

PwmHwConfiguration Configuration

 

Here break open

Note here the name and where to use?

Name here only for identification purposes, not used in the code, the main program using the name PwmChannel

 

Seven, the main program

Pwm_Init(&PwmChannelConfigSet);

int step_led_red = 0;

void Gpt_LPIT0_Notification(void)

{

    step_led_red +=10;

    if(step_led_red > 0x8000)

    {

        step_led_red = 0;

    }

    Pwm_SetPeriodAndDuty(PWM_FTM0_CH0_RGB_LED,800,step_led_red);

}

Eight function parameter analysis

void Pwm_SetPeriodAndDuty (

Pwm_ChannelType ChannelNumber,

Pwm_PeriodType Period,

uint16 DutyCycle)

Second cycle parameter, the parameter is the duty cycle three.

Duty cycle: Pwm module duty cycle scaling scheme should meet the following

0x0000 means that the duty cycle is 0%

0x8000 means that 100% duty cycle

Published 39 original articles · won praise 29 · views 30000 +

Guess you like

Origin blog.csdn.net/wx601056818/article/details/104823619