📄 initialization.c
字号:
#include "BF533 Flags.h"
//--------------------------------------------------------------------------//
// Function: Init_Flags //
// //
// Parameters: None //
// //
// Return: None //
// //
// Description: This function configures PF8 as input for edge sensitive //
// interrupt generation. //
// The switch connected to PF8 (SW7) can be used to change the //
// direction of the moving light. //
//--------------------------------------------------------------------------//
void Init_Flags(void)
{
*pFIO_INEN = 0x0001;
*pFIO_DIR = 0x0010;//pf4: out
//*pFIO_EDGE = 0x0004;
//*pFIO_MASKA_D = 0x0004;
}
//--------------------------------------------------------------------------//
// Function: Init_Timers //
// //
// Parameters: None //
// //
// Return: None //
// //
// Description: This function initialises Timer0 for PWM mode. //
// It is used as reference for the 'shift-clock'. //
//--------------------------------------------------------------------------//
void Init_Timers(void)
{
*pTIMER0_CONFIG = 0x0019;
//*pTIMER0_PERIOD = 0x06c00000;//6d3a06d3
*pTIMER0_PERIOD = 0x00003057;//:9600BPS
*pTIMER0_WIDTH = 0x00003057;
*pTIMER_ENABLE = 0x0001;
}
//--------------------------------------------------------------------------//
// Function: Init_EBIU //
// //
// Parameters: None //
// //
// Return: None //
// //
// Description: This function initialises and enables the asynchronous //
// memory banks for the External Bus Interface Unit (EBIU), so //
// that access to Flash A is possible. //
//--------------------------------------------------------------------------//
void Init_EBIU(void)
{
*pEBIU_AMBCTL0 = 0x7bb07bb0;
*pEBIU_AMBCTL1 = 0x7bb07bb0;
*pEBIU_AMGCTL = 0x000f;
}
//--------------------------------------------------------------------------//
// Function: Init_Interrupts //
// //
// Parameters: None //
// //
// Return: None //
// //
// Description: This function initialises the interrupts for Timer0 and //
// FlagA (PF8). //
//--------------------------------------------------------------------------//
void Init_Interrupts(void)
{
// assign core IDs to interrupts
*pSIC_IAR0 = 0xffffffff;
*pSIC_IAR1 = 0xffffffff;
*pSIC_IAR2 = 0xffff5ff4; // Timer0 -> ID4; FlagA -> ID5
// assign ISRs to interrupt vectors
register_handler(ik_ivg11, Timer0_ISR); // Timer0 ISR -> IVG 11
// enable Timer0 and FlagA interrupt
*pSIC_IMASK = 0x00090000;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -