Electoday 4.0
ไมโครคอนโทรลเลอร์ => ARM Processors => Topic started by: tha on July 28, 2022, 09:01:55 am
-
10 HAL CORTEX Generic Driver
10.1 CORTEX Firmware driver API description
ส่วนต่อไปนี้แสดงรายการ the various functions of the CORTEX library.
10.1.1 How to use this driver
วิธีกำหนดค่า Interrupts โดยใช้ CORTEX HAL driver
ส่วนนี้จัดให้มีฟังก์ชันที่อนุญาตให้กำหนดค่า the NVIC interrupts (IRQ). The Cortex-M3 exceptions ถูกจัดการโดย CMSIS functions.
1. กำหนดค่า the NVIC Priority Grouping โดยใช้ HAL_NVIC_SetPriorityGrouping() function สอดคล้องกับ the following
table.
2. กำหนดค่า the priority ของ the selected IRQ Channels โดยใช้ HAL_NVIC_SetPriority().
3. เปิดใช้งาน the selected IRQ Channels โดยใช้ HAL_NVIC_EnableIRQ().
4. โปรดดูที่ programming manual สำหรับรายละเอียดเกี่ยวกับวิธีกำหนดค่า priority.
Note: เมื่อ the NVIC_PRIORITYGROUP_0 ถูกเลือก, IRQ preemption ไม่สามารถทำได้อีกต่อไป. The pending IRQ
priority จะถูกจัดการได้เพียงโดย the sub priority.
Note: IRQ priority order (จัดเรียงตาม highest ไปยัง lowest priority):
– Lowest preemption priority
– Lowest sub priority
– Lowest hardware priority (IRQ number)
-
วิธีกำหนดค่า Systick โดยใช้ CORTEX HAL driver
การตั้งค่า SysTick Timer สำหรับ time base.
• The HAL_SYSTICK_Config()function เรียก the SysTick_Config() function ซึ่งเป็น a CMSIS function ที่:
– กำหนดค่า the SysTick Reload register ด้วยค่าที่ผ่านเป็น function parameter.
– กำหนดค่า the SysTick IRQ priority เป็น the lowest value 0x0F.
– รีเซ็ต the SysTick Counter register.
– กำหนดค่า the SysTick Counter clock source เป็น Core Clock Source (HCLK).
– เปิดใช้งาน the SysTick Interrupt.
– สตาร์ท the SysTick Counter.
• คุณสามารถเปลี่ยน the SysTick Clock source เป็น HCLK_Div8 โดยการเรียก the macro
__HAL_CORTEX_SYSTICKCLK_CONFIG(SYSTICK_CLKSOURCE_HCLK_DIV8) เพียงหลังจากการเรียก the
HAL_SYSTICK_Config() function. The __HAL_CORTEX_SYSTICKCLK_CONFIG() macro ถูกกำหนดไว้ภายใน the
stm32f1xx_hal_cortex.h file.
• คุณสามารถเปลี่ยน the SysTick IRQ priority โดยการเรียก the HAL_NVIC_SetPriority(SysTick_IRQn,...) function เพียง
หลังจากการเรียก the HAL_SYSTICK_Config() function. The HAL_NVIC_SetPriority() เรียก the NVIC_SetPriority()
function ซึ่งเป็น a CMSIS function.
• เพื่อปรับ the SysTick time base, ใช้ the following formula: Reload Value = SysTick Counter Clock (Hz) x Desired
Time base (s)
– Reload Value คือ the parameter ที่จะถูกส่งผ่านสำหรับ HAL_SYSTICK_Config() function
– Reload Value ควรไม่เกิน 0xFFFFFF
-
10.1.2 Initialization and de-initialization functions
ส่วนนี้จัดให้มี the CORTEX HAL driver functions ที่อนุญาตให้กำหนดค่า Interrupts Systick functionalities
ส่วนนี้บรรจุ the following APIs:
• HAL_NVIC_SetPriorityGrouping
• HAL_NVIC_SetPriority
• HAL_NVIC_EnableIRQ
• HAL_NVIC_DisableIRQ
• HAL_NVIC_SystemReset
• HAL_SYSTICK_Config
-
10.1.3 Peripheral Control functions
ส่วนย่อยนี้จัดให้มี a set of functions ที่อนุญาตให้ควบคุม the CORTEX (NVIC, SYSTICK, MPU) functionalities.
ส่วนนี้บรรจุ the following APIs:
• HAL_NVIC_GetPriorityGrouping
• HAL_NVIC_GetPriority
• HAL_NVIC_SetPendingIRQ
• HAL_NVIC_GetPendingIRQ
• HAL_NVIC_ClearPendingIRQ
• HAL_NVIC_GetActive
• HAL_SYSTICK_CLKSourceConfig
• HAL_SYSTICK_IRQHandler
• HAL_SYSTICK_Callback
-
(https://i.imgur.com/MJyPhKO.png)
-
(https://i.imgur.com/jy7WYRK.png)
(https://i.imgur.com/EJ9htZs.png)
-
(https://i.imgur.com/sINDb1i.png)
-
(https://i.imgur.com/PZiGTOn.png)
-
(https://i.imgur.com/XvPZ3aJ.png)
-
(https://i.imgur.com/XRegAVz.png)
-
(https://i.imgur.com/QspcnCW.png)
-
(https://i.imgur.com/VY4OV1p.png)
-
(https://i.imgur.com/ePkwVpg.png)
(https://i.imgur.com/jnGotdH.png)
-
(https://i.imgur.com/DIbkfmj.png)
-
(https://i.imgur.com/IzKuNPF.png)
-
(https://i.imgur.com/vVYffgQ.png)
(https://i.imgur.com/MH0nr5z.png)
-
(https://i.imgur.com/Jv1QgqF.png)
-
(https://i.imgur.com/OkDvmsH.png)
-
(https://i.imgur.com/D3fO5Pq.png)
-
(https://i.imgur.com/pRJiAjm.png)
(https://i.imgur.com/rZmhg8f.png)
-
จบตอน