First, the purpose of the experiment
(1) be familiar with configuration parameters GPT, the actual operation to identify problems reading the document did not pay attention
(2) achieve timer interrupt, change the LED level
Second, the experimental environment
Window10
Server: windows
And server interaction software winscp574 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
DIO is already configured in a test, and there is no longer involved.
1. Modify MCAL in the EB configuration GPT
2. Verify the configuration in the EB, the output generating the output file
MCAL MCAL project file 3. Copy the template project file replacement project
4. Perform batch file copy the template project file, copied to the specified location
5. By winscp uploaded to the server project
6. compile command putty
7. Compile a nice project to the local download
8. By ic5000 download debugging, observable phenomena
Four, GPT configuration
The first step in configuring hardware
Step configuration reference clock
Reference clock configured by the MCU >> McuClockSetting >> McuClockSettingConfig_0 >> McuClockReferencePoint to give the tab.
Configuration Description: chip manual search of the chip through LPIT keywords, you can get the following figure, from which we can see what the input clock source, choose a suitable. Here select LPIT_CLK
The third step is also configured GPT channel notification function
The fourth step also configure the project in the interrupt vector table
Files involved are: Vector_core.s loHwAB.c s32k146.h
As a function of inlet Vector_core.s
s32k146.h defines the interrupt number
loHwAB.c file registered interrupt according to the interrupt number and interrupt handling function name
The specific implementation is as follows (refer to code that can be read vertically):
Fifth, code implementation
Initialization part
Gpt_Init(&GptChannelConfigSet);
Gpt_EnableNotification(GptConf_GptChannelConfiguration_GptChannelConfiguration_0);
Gpt_StartTimer(GptConf_GptChannelConfiguration_GptChannelConfiguration_0, 4000000);//40000为1ms
About regular time: set a clock source, the frequency of the clock source is here 4.0E7, it needs to count the timing 1ms to 40,000 , cycle, frequency, and to figure out the tick.
Achieve some
void Gpt_LPIT0_Notification(void)
{
static int RGB_LED_status = 0;
if(RGB_LED_status==0)
RGB_LED_status =1;
else
RGB_LED_status =0;
Dio_WriteChannel(DioConf_DioChannel_RGB_LED,RGB_LED_status);
}