You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

67 lines
1.5 KiB

  1. #include "MKV56F24.h"
  2. #include "fsl_common.h"
  3. #include "fsl_gpio.h"
  4. #include "fsl_port.h"
  5. /*********************************************
  6. PTA15——LED灯闪烁
  7. **********************************************/
  8. volatile uint32_t g_systickCounter;
  9. void SysTick_DelayTicks(uint32_t n); //滴答定时器延时函数
  10. void main()
  11. {
  12. CLOCK_EnableClock(kCLOCK_PortA); //开启PORT时钟
  13. port_pin_config_t GPIO_Port_Init =
  14. {
  15. kPORT_PullUp , //上拉
  16. kPORT_FastSlewRate, //快速压摆率
  17. kPORT_PassiveFilterDisable, //无源滤波器
  18. kPORT_OpenDrainDisable, //推挽输出
  19. kPORT_LowDriveStrength, //低驱动力
  20. kPORT_MuxAsGpio, //普通GPIO模式
  21. kPORT_UnlockRegister, //
  22. };
  23. PORT_SetPinConfig(PORTA, 15U, &GPIO_Port_Init); //设置引脚复用方式
  24. gpio_pin_config_t config =
  25. {
  26. kGPIO_DigitalOutput, //输出模式
  27. 0,
  28. };
  29. GPIO_PinInit(GPIOA, 15U, &config); //初始化PTA15
  30. GPIO_PinWrite(GPIOA, 15, 1); //PTA15写1
  31. /* Set systick reload value to generate 1ms interrupt */
  32. if (SysTick_Config(SystemCoreClock / 1000U))
  33. {
  34. while (1)
  35. {
  36. }
  37. }
  38. while (1)
  39. {
  40. GPIO_PinWrite(GPIOA, 15, 0);
  41. SysTick_DelayTicks(500U);
  42. GPIO_PinWrite(GPIOA, 15, 1);
  43. SysTick_DelayTicks(500U);
  44. }
  45. }
  46. void SysTick_Handler(void)
  47. {
  48. if (g_systickCounter != 0U)
  49. {
  50. g_systickCounter--;
  51. }
  52. }
  53. void SysTick_DelayTicks(uint32_t n)
  54. {
  55. g_systickCounter = n;
  56. while (g_systickCounter != 0U)
  57. {
  58. }
  59. }