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

📄 cpu.c

📁 SPI主机模式进行串行通信
💻 C
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : Cpu.C
**     Project   : spi_master
**     Processor : 56F8346
**     Beantype  : 56F8346
**     Version   : Bean 01.048, Driver 01.27, CPU db: 2.87.097
**     Datasheet : MC56F8346/D Rev. 1.0, MC56F8300UM/D - Rev. 1.0
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 2009-1-16, 8:43
**     Abstract  :
**
**     Settings  :
**
**     Contents  :
**         EnableInt   - void Cpu_EnableInt(void);
**         DisableInt  - void Cpu_DisableInt(void);
**         SetWaitMode - void Cpu_SetWaitMode(void);
**         SetStopMode - void Cpu_SetStopMode(void);
**         SetDataMode - void Cpu_SetDataMode(byte Mode);
**
**     (c) Freescale Semiconductor
**     2004 All Rights Reserved
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2005
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/

/* MODULE Cpu. */
#include "slave_select.h"
#include "PC_M1.h"
#include "Inhr1.h"
#include "SM1.h"
#include "Delay_timer.h"
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "Events.h"
#include "Cpu.h"


/* Global variables */
volatile word SR_lock=0;               /* Lock */
volatile word SR_reg;                  /* Current value of the SR register */
/*
** ===================================================================
**     Method      :  Cpu_Interrupt (bean 56F8346)
**
**     Description :
**         The method services the interrupt of the selected peripheral(s)
**         and eventually invokes the beans event(s).
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
#pragma interrupt alignsp
void Cpu_Interrupt(void)
{
  asm(DEBUGHLT);                       /* Halt the core and placing it in the debug processing state */
}

/*
** ===================================================================
**     Method      :  Cpu_DisableInt (bean 56F8346)
**
**     Description :
**         Disables all maskable interrupts
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_DisableInt(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_EnableInt (bean 56F8346)
**
**     Description :
**         Enables all maskable interrupts
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_EnableInt(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_SetStopMode (bean 56F8346)
**
**     Description :
**         Sets low power mode - Stop mode.
**         For more information about the stop mode see this CPU
**         documentation.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_SetStopMode(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_SetWaitMode (bean 56F8346)
**
**     Description :
**         Sets low power mode - Wait mode.
**         For more information about the wait mode see this CPU
**         documentation.
**         Release from wait mode: Reset or interrupt
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_SetWaitMode(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_SetDataMode (bean 56F8346)
**
**     Description :
**         Sets the Data memory map to use either internal &
**         external resources or external resources only.
**     Parameters  :
**         NAME            - DESCRIPTION
**         Mode            - Data memory access mode.
**                           Possible modes:
**                           INT_EXT_MODE - use internal & external
**                           resources
**                           EXT_MODE - use external resources only
**     Returns     : Nothing
** ===================================================================
*/
void Cpu_SetDataMode(byte Mode)
{
  if (Mode == INT_EXT_MODE)
    asm { bfclr  #0x0008,OMR }         /* Set internal and external data memory mode */
  else
    asm { bfset  #0x0008,OMR }         /* Set external data memory mode */
}

/*
** ===================================================================
**     Method      :  _EntryPoint (bean 56F8346)
**
**     Description :
**         Initializes the whole system like timing and so on. At the end 
**         of this function, the C startup is invoked to initialize stack,
**         memory areas and so on.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
extern void init_56800_(void);         /* Forward declaration of external startup function declared in startup file */

/*** !!! Here you can place your own code using property "User data declarations" on the build options tab. !!! ***/

void _EntryPoint(void)
{

  /*** !!! Here you can place your own code before PE initialization using property "User code before PE initialization" on the build options tab. !!! ***/

  /*** ### 56F8346 "Cpu" init code ... ***/
  /*** PE initialization code after reset ***/
  /* System clock initialization */
  setReg(PLLCR, (PLLCR_LCKON_MASK | PLLCR_ZSRC0_MASK)); /* Enable PLL, LCKON and select clock source from prescaler */
  /* PLLDB: LORTP=2,PLLCOD=0,PLLCID=1,??=0,PLLDB=59 */
  setReg16(PLLDB, 8507);               /* Set the clock prescalers */ 
  while(!getRegBit(PLLSR, LCK0)){}     /* Wait for PLL lock */
  setReg(PLLCR, (PLLCR_LCKON_MASK | PLLCR_ZSRC1_MASK)); /* Select clock source from postscaler */
  /* FMCLKD: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,DIVLD=0,PRDIV8=1,DIV=18 */
  setReg16(FMCLKD, 82);                /* Set the flash clock prescaler */ 
  /*** End of PE initialization code after reset ***/

  /*** !!! Here you can place your own code after PE initialization using property "User code after PE initialization" on the build options tab. !!! ***/

  asm(JMP init_56800_);                /* Jump to C startup code */
}

/*
** ===================================================================
**     Method      :  PE_low_level_init (bean 56F8346)
**
**     Description :
**         Initializes beans and provides common register initialization. 
**         The method is called automatically as a part of the 
**         application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  /* TSENSOR_CONTROL: PWR=0 */
  clrReg16Bits(TSENSOR_CONTROL, 1);    /* Disable power source for the temperature sensor */ 
  /* Common initialization of the CPU registers */
  /* GPIO_E_IENR: IEN&=~128 */
  clrReg16Bits(GPIO_E_IENR, 128);       
  /* GPIO_E_IAR: IA&=~128 */
  clrReg16Bits(GPIO_E_IAR, 128);        
  /* GPIO_E_IESR: IES|=128 */
  setReg16Bits(GPIO_E_IESR, 128);       
  /* GPIO_E_PPMODE: PPMODE|=128 */
  setReg16Bits(GPIO_E_PPMODE, 128);     
  /* GPIO_E_DR: D&=~16,D|=128 */
  clrSetReg16Bits(GPIO_E_DR, 16, 128);  
  /* GPIO_E_DDR: DD|=144 */
  setReg16Bits(GPIO_E_DDR, 144);        
  /* GPIO_E_PER: PE&=~144,PE|=99 */
  clrSetReg16Bits(GPIO_E_PER, 144, 99); 
  /* INTC_IPR8: SCI0_RCV_IPL=2,SCI0_RERR_IPL=2,SCI0_TIDL_IPL=2,SCI0_XMIT_IPL=2 */
  clrSetReg16Bits(INTC_IPR8, 20800, 41600); 
  /* INTC_IPR7: TMRA_0_IPL=2 */
  clrSetReg16Bits(INTC_IPR7, 16384, 32768); 
  /* ### Asynchro serial "Inhr1" init code ... */
  Inhr1_Init();
  /* ### PC_Master "PC_M1" init code ... */
  PC_M1_PE_Init();
  /* ### SynchroMaster "SM1" init code ... */
  SM1_Init();
  /* ### TimerInt "Delay_timer" init code ... */
  Delay_timer_Init();
  __EI(0);                             /* Enable interrupts of the selected priority level */
}

/* END Cpu. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 2.97 [03.74]
**     for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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