⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.c

📁 以ST公司CPU为核心的彩色电视机的完整源程序。
💻 C
字号:
#include "st92196.h"
#include "register.h"
#include "macro.h"
#include "utility.h"
#include "init.h"

/****************************************************************************
INPUT       : none
OUTPUT      : none
DESCRIPTION : initialize interrupts
*****************************************************************************/
void init_IT(void)
{
    spp(EXINT_PG);       /* set page to external interrupt registers */		 

    CICR = 0x0F;         /* Global counter disabled, CPL = 7, nested mode */

    EIVR = 0x10;         /* set most significant nibble of external interrupt vector */
    EIVR |= EIm_ewenm;   /* external wait enabled */
    EIVR |= EIm_iaosm;   /* External interrupt pin is source for A0 */
    EIVR |= EIm_tlism;   /* External NMI pin for Top Level Interrupt */
    EIVR |= EIm_tltevm;  /* Top level event on the rising edge of NMI pin */	

    EITR = 0xDF;	     /* pending bit set on rising edge of the signal */

    EIPR = 0x00;	     /* clear all pendings interrupts */

    EIMR = 0x9A;	     /* interrupt mask disabled :
                              b7 = IR preprocessor /INT7 -1
							  b6 = Data Slicers /INT6    -0
							  b5 = ADC / INT5            -0
							  b4 = OSD                   -1 
							  b3 = I2C                   -1
							  b2 = SPI / INT2            -0
							  b1 = STD Timer / INT1      -1
							  b0 = WDT / INT0            -0
                         */
			    /* INT5 will be set in the osd_enabled subroutine
                this IT must not be initialised before, because while program is
                in the hello() sub, no OSD is initialised in memory, so no refresh
                IT must be authorized */

    EIPLR = 0x1A;     /* set priority level for ITs :
                         0 for CC (data slicers ) -Not use
                         1 for IR
                         2 for OSD 
                         3 for INT5, 
                         4 for other channels xx0 & priority level
                         5 for channel x1 (STD Timer and I2C) 
                      */

    NICR = 0x00;      /* reset nested mode register */
}

/*================================================================================================
       init_tcc
--------------------------------------------------------------------------------------------------
Meaning : initialize timing and clock controller

Input : none

Output : none
==================================================================================================*/
void init_TCC(void)
{
/*	unsigned int i, imax; */
	
	spp(TIMING_PG);

	MCCR = 0x0B;                    /* program the frequency multiplier down
				freq=( 4 +1)*2 =10Mhz
				freq=( 5 +1)*2 =12Mhz
				freq=( 6 +1)*2 =14Mhz
				freq=( 7 +1)*2 =16Mhz
				freq=( 8 +1)*2 =18Mhz
				freq=( 9 +1)*2 =20Mhz
				freq=( 10 +1)*2 =22Mhz
				freq=( 11 +1)*2 =24Mhz */

	MCCR |= TIMINGm_FMEN;           /* enable the freq. multiplier */

	SKCCR = 0x00;                   /* program the pixel clock down */
	SKCCR &= ~TIMINGm_SKDIV2;       /* reset SKDIV2 bit if Xtal frequency is 4 MHz, set if 8 MHz */
    SKCCR |= 0x06;              /* set the pixel clock frequency using this table :
						Value       FPIXC          Pixel Clk Freq
						      (see OSDER register)
						  6           0                14 MHz
						  7           0                16 MHz
						  8           0                18 MHz
						  9           0                20 MHz
						  A           0                22 MHz
						  B           0                24 MHz
						  C           0                26 MHz
						  6           1                28 MHz
						  E           0                30 MHz
						  7           1                32 MHz
						  8           1                36 MHz
						  9           1                40 MHz*/

	SKCCR |= TIMINGm_SKWEN;         /* pixel clock enabled */


	millisecond_delay(35);

	MCCR |= TIMINGm_FMSL;           /* select the freq. multiplier as main clock */
}

/*================================================================================================
       init_rccu
--------------------------------------------------------------------------------------------------
Meaning : initialize RCCU

Input : none

Output : none
==================================================================================================*/
void init_RCCU(void)
{
	spp(RCCU_PG);                   /* select RCCU page */
	CLKCTL |= ~Cm_sresen;   /* Halt instruction stops PLL */
}

/*================================================================================================
      INIT SCI
--------------------------------------------------------------------------------------------------
Meaning : initialize sci for mouse communication

Input : none

Output : none
==================================================================================================*/

void init_SCI(void)
{
	spp(SCI0_PG);       /* set page to SCI0 registers */
	S_BRGHR = ((1250 & 0xFF00)>>8);   /* set the baud rate generator 24MHz & 1200 bauds => divided by 1250 HIGH byte */
	S_IVR = 0x34;       /* set interrupt on receiver data ready */
	S_IMR = 0x02;       /* Receiver data pending generate interrupt */
	S_IDPR = 0x03;      /* Priority level = 3 */
	S_CHCR = 0x0A;      /* no parity, 2 stop bits, 7 data bits */
	S_CCR = 0x00;       /* 16X mode enabled */
	S_SICR = 0x00;      /* synchonous mode disabled */

    S_SOCR = 0x00;      /* kelvin: polarity not inverted - sout stand-by is high */

	S_ISR = 0x00;       /* clear all pending SCI IT */

	S_BRGLR = (1250 & 0x00FF);  /* set the baud rate generator 24MHz & 1200 bauds => divided by 1250 LOW byte to enable SCI*/
}

/*================================================================================================
      INIT ADC
--------------------------------------------------------------------------------------------------
Meaning : initialize ADC

Input : none

Output : none
==================================================================================================*/
void init_ADC(void)
{
    spp(FAD_PG);          /* set page pointer to A to D converter */
    FAD_CLR = (FADm_channel_1 | FADm_fs_slow | FADm_pow_dis | FADm_str_stop); /* set channel = 1 pin2.1 */
						    /* slow mode */
						    /* power enable */
						    /* start conversion */
    FAD_INT = 0x00;       /* No A/D interrupt selected as interrupt source (only used EXT5) */
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -