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

📄 fesc_5554_emios.c

📁 MPC5554处理器的初始化例程
💻 C
字号:
/*
EMISO   0,1  FPGA输出的两个脉冲信号,可以作为外部中断触发信号
EMIOS   2,3  在FPGA里面直连控制前面板的主备机LED//低电平点亮,FPGA里对两个CPU的信号进行或
EMIOS   4    取2错误的指示
EMIOS   5
EMIOS   6  两个CPU都完成MF通道的帧接收后,FPGA给出一个中断呼叫
EMISO   7  FPGA给出的主控板系间通信SPI的Busy信号,用其下降沿可以作为接收触发信号
------------------------------
EMIOS     8  generate SSP LOOP period
EMIOS     9  generate Communicate daemon period
EMIOS     10 generate system tick
EMIOS     11,12,13,14  not used yet
EMIOS 15-23  control LEDs
*/



/******************************************/
/* @2                                     */
/*         ----------------------         */
/*                                        */
/******************************************/ 
void init_EMIOS(void) {
  uint8_t i;
  EMIOS.MCR.B.GPRE= 119;         /* Divide 120MHz sysclk by 119+1 for 1MHz eMIOS clk*/
  //EMIOS.MCR.B.GPRE= 127;         /* Divide 128MHz sysclk by 127+1 for 1MHz eMIOS clk*/
  EMIOS.MCR.B.GPREN = 1;         /* Enable eMIOS clock */
  EMIOS.MCR.B.GTBE = 1;          /* Enable global time base */
  EMIOS.MCR.B.FRZ = 1;           /* Enable stopping channels when in debug mode */
  
  set_GPIO(PIN_EMIOS2,1);
  set_GPIO(PIN_EMIOS3,1);
  set_GPIO(PIN_EMIOS4,1);
  pad_func_config(PIN_EMIOS2,GPIO_FUNCTION | OUTPUT_MODE | DRIVE_STRENGTH_50PF );  //GPIO OUTPUT
  pad_func_config(PIN_EMIOS3,GPIO_FUNCTION | OUTPUT_MODE | DRIVE_STRENGTH_50PF );  //GPIO OUTPUT
  pad_func_config(PIN_EMIOS4,GPIO_FUNCTION | OUTPUT_MODE | DRIVE_STRENGTH_50PF );  //GPIO OUTPUT

  /* Setup EMIOS15-23 as LED control pins */
  for(i=0;i<9;i++)
  { pad_func_config(PIN_EMIOS15+i,GPIO_FUNCTION | OUTPUT_MODE | DRIVE_STRENGTH_50PF );  //GPIO OUTPUT
    set_led(PIN_EMIOS15+i,1);
  }
}
/******************************************/
/*   当两个CPU都完成MF通道的帧接收后      */
/*      FPGA呼叫一个中断信号              */
/*                                        */
/******************************************/
void init_FPGA_GEN_MF_SPI_ALL_DONE_IRQ(void)
{
  EMIOS.CH[6].CCR.B.UCPREN = 1;    /* Enable prescaler; uses default divide by 1 */
  EMIOS.CH[6].CCR.B.BSL    = 0x3;  /* Use internal counter */
  EMIOS.CH[6].CCR.B.FCK    = 0;    /* use prescaled clock for filter */
  EMIOS.CH[6].CCR.B.IF     = 0x00; /* 16 filter clock periods */
  EMIOS.CH[6].CCR.B.EDSEL  = 0;    /* sentive on single edge */
  EMIOS.CH[6].CCR.B.EDPOL  = 1;    /* capture rising edge */
  EMIOS.CH[6].CCR.B.MODE   = 0x02; /* single action input capture */
  EMIOS.CH[6].CCR.B.FREN   = 1;    /* Stop (freeze) channel registers when in debug mode */
  EMIOS.CH[6].CCR.B.FEN    = 1;    /* Flag enables interrupt */
  INTC.PSR[51+6].R         = SPIRX_SCAN_TASK_PRIORITY; /* eMIOS chan 0 IRQ priority */
  /* EMIOS 0 */
  pad_func_config(PIN_EMIOS6,PRIMARY_FUNCTION+READBACK_ENABLE); //EMIOS0
	
	}
/******************************************/
/*       外部FPGA产生的MF-SPI(7)接收中断  */
/*         ----------------------         */
/*           busy信号的下降沿直接触发     */
/******************************************/
void init_FPGA_GEN_MF_SPI_slave_DAEMON_IRQ(void)
{
  EMIOS.CH[7].CCR.B.UCPREN = 1;    /* Enable prescaler; uses default divide by 1 */
  EMIOS.CH[7].CCR.B.BSL    = 0x3;  /* Use internal counter */
  EMIOS.CH[7].CCR.B.FCK    = 0;    /* use prescaled clock for filter */
  EMIOS.CH[7].CCR.B.IF     = 0x00; /* 16 filter clock periods */
  EMIOS.CH[7].CCR.B.EDSEL  = 0;    /* sentive on single edge */
  EMIOS.CH[7].CCR.B.EDPOL  = 0;    /* capture falling edge */
  EMIOS.CH[7].CCR.B.MODE   = 0x02; /* single action input capture */
  EMIOS.CH[7].CCR.B.FREN   = 1;    /* Stop (freeze) channel registers when in debug mode */
  EMIOS.CH[7].CCR.B.FEN    = 1;    /* Flag enables interrupt */
  INTC.PSR[51+7].R         = SPIRX_SCAN_TASK_PRIORITY; /* eMIOS chan 0 IRQ priority */
  /* EMIOS 0 */
  pad_func_config(PIN_EMIOS7,PRIMARY_FUNCTION+READBACK_ENABLE); //EMIOS0
}


/******************************************/
/* 用内部EMIOS产生的主循环触发中断        */
/*         ----------------------         */
/*             ~100ms                    */
/******************************************/ 
void init_EMIOS_GEN_SSP_LOOP_IRQ(void)
{
  /* SSP_LOOP_TASK, self generated */
  EMIOS.CH[8].CBDR.R = SSP_TICK_PERIOD;     /* Period is 1000 eMIOS clocks (1 msec) */
  EMIOS.CH[8].CADR.R = SSP_TICK_PERIOD/2;   /* Duty cycle is 500 eMIOS clocks, 50% */
  EMIOS.CH[8].CCR.B.MODE = 0x18; /* Mode is Output pulse width + freq. modulation */
  EMIOS.CH[8].CCR.B.BSL = 0x3;   /* Use internal counter */
  EMIOS.CH[8].CCR.B.FREN = 1;    /* Stop (freeze) channel registers when in debug mode */
  EMIOS.CH[8].CCR.B.FEN=1;       /* Flag enables interrupt */
  EMIOS.CH[8].CCR.B.UCPREN = 1;  /* Enable prescaler; uses default divide by 1 */
  INTC.PSR[51+8].R = SSP_LOOP_TASK_PRIORITY; /* eMIOS chan 8 IRQ priority */
}

/******************************************/
/* 用内部EMIOS产生的SPI发送轮循中断        */
/*         ----------------------         */
/*             ~200us                  */
/******************************************/
void init_EMIOS_GEN_SPI_master_DAEMON_IRQ(void)
{
  /* daemon Task */
  EMIOS.CH[9].CBDR.R = SPI_MASTER_DAEMON_PERIOD;      /* Period is 100 eMIOS clocks (0.1 msec) */
  EMIOS.CH[9].CADR.R = SPI_MASTER_DAEMON_PERIOD/2;       /* Duty cycle is 500 eMIOS clocks, 50% */
  EMIOS.CH[9].CCR.B.MODE = 0x18; /* Mode is Output pulse width + freq. modulation */
  EMIOS.CH[9].CCR.B.BSL = 0x3;   /* Use internal counter */
  EMIOS.CH[9].CCR.B.FREN = 1;    /* Stop (freeze) channel registers when in debug mode */
  EMIOS.CH[9].CCR.B.FEN=1;       /* Flag enables interrupt */
  EMIOS.CH[9].CCR.B.UCPREN = 1;  /* Enable prescaler; uses default divide by 1 */
  INTC.PSR[51+9].R = SPITX_SCAN_TASK_PRIORITY; /* eMIOS chan 9 IRQ priority */
}




⌨️ 快捷键说明

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