资源简介

S12G128的CAN唤醒功能。里面还有很多调好的功能模块,底层基本全部搞了。这里主要的是CAN的中断唤醒,以及S12G128的休眠功能。

资源截图

代码片段和文件信息


#include “user.h“ 

INT32U Time1;

void delay_Mms(int ms)
{   
    int ij;
    if(ms<1) ms=1;
    for(i=0;i        //for(j=0;j<1333;j++);    //fBUS=8MHz时-->1ms
        //for(j=0;j<2666;j++);    //fBUS=16MHz时-->1ms        
        //for(j=0;j<5332;j++);    //fBUS=32MHz时-->1ms        
        for(j=0;j<10664;j++);   //fBUS=64MHz时-->1ms        
        //for(j=0;j<13330;j++);   //fBUS=80MHz时-->1ms        
        //for(j=0;j<15996;j++);   //fBUS=96MHz时-->1ms        
}

CANMsg CAN_msg;
void init_canMsg(void)    
{
  u8 state;
  //Perp_Init();
  CAN_msg.ID = 0x18FF0CEC;
  CAN_msg.RTR = 0 ;
  CAN_msg.dataLen = 8;
  for(state = 0 ;state<8 ; state++)
  CAN_msg.data[state] = 0x00 ;
  CAN_msg.priority = 0 ;
  CAN_msg.data[0] =0xFF;
  CAN_msg.data[1] = 0xFF;
}

void Drv_GPIO_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStruct;
    
    GPIO_InitStruct.GPIO_Pin =Pin4;  //选择引脚
    GPIO_InitStruct.State =RESET;                //初始化状态
    GPIO_InitStruct.Mode = GPIO_Mode_OUT;      //设置输出
    GPIO_Init(GPIOS&GPIO_InitStruct);         //初始化
    GPIO_SetBits(GPIOSPin4);
    
    GPIO_InitStruct.GPIO_Pin =Pin7|Pin6;  //选择引脚
    GPIO_InitStruct.State =SET;                //初始化状态
    GPIO_InitStruct.Mode = GPIO_Mode_OUT;      //设置输出
    GPIO_Init(GPIOB&GPIO_InitStruct);         //初始化
    GPIO_ClrBits(GPIOBPin7); 
   
    GPIO_InitStruct.GPIO_Pin =Pin7;  //选择引脚
    GPIO_InitStruct.State =SET;                //初始化状态
    GPIO_InitStruct.Mode = GPIO_Mode_IPU;      //设置输入
    GPIO_Init(GPIOADH&GPIO_InitStruct);         //初始化
     
   
    DDRJ_DDRJ6 = 1; 
    PTJ_PTJ6 = 0;
    
    
}

void Drv_Init(void)
{
    SystemClock128M_Init(); //系统初始化 BUSCLOCK= 64M
    Drv_GPIO_Init();
    Drv_API_Init();
    Drv_RTI_Init(2);  //tick delay generator 2ms interrupt
    
   // TIM_US_Init(50000);  //before set TIM need set the  cycleMAX NUM 65535us
   // OutputCompare_Init();
    //Drv_ADC_Init(); 
    MSCAN_Init(Baud_500k DISABLE);
    init_canMsg();
}


void main(void)
{
  u8 state;
  INT16U   ad_ch = 0;
  INT16U   ad_ch1 = 0;
  INT16U   ad_ch2 = 0;
  INT16U   ad_ch3 = 0;
  INT8U    CNT_Times = 0;
  INT16U   CNT_Times1 = 0;
  /* put your own code here */
  Drv_Init();
  EnableInterrupts;

  //asm ANDCC #0x7F;  //clear S bit = enable stop mode
 // ApiTimer_ENABLE();
  for(;;) 
  {
/*     ad_ch = ADC_GetValue(1);
     ad_ch1 = ADC_GetValue(0);
      ad_ch3 = ADC_GetValue(8);
    
      ad_ch2 = ADC_GetValue(9); */
  
   if(CNT_Times<50)
   {
       CNT_Times ++; 
       delay_Mms(500);
       GPIO_ToggleBits(GPIOSPin4);
           CANSendMsg(&CAN_msg);
       state=0;
   }
   
     if(CNT_Times == 50)
    {
        CNT_Times1++;
        Go_Full_StopMode();
        CNT_Times = 0;
    }
    
   /* if(CNT_Times1 == 6)
    {
        CNT_Times1 = 0;
        ApiTimer_DISABLE();
    } */
    _FEED_COP(); /* feeds the dog */

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-13 07:54  S12G128_CAN_WakeUp_Interrupt\
     文件         855  2018-01-19 15:44  S12G128_CAN_WakeUp_Interrupt\C_Layout.hwl
     文件         161  2004-06-15 15:46  S12G128_CAN_WakeUp_Interrupt\Default.mem
     文件       64538  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM.mcp
     目录           0  2018-12-13 07:44  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\
     文件        4365  2018-12-13 07:55  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\CWSettingsWindows.stg
     目录           0  2018-12-13 07:44  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\
     目录           0  2018-12-13 07:44  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\
     文件       13372  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Adc_dri.c.o
     文件        9508  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Api_dri.c.o
     文件       23488  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Can_dri.c.o
     文件        9120  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Clk_dri.c.o
     文件       15160  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Gpio_dri.c.o
     文件        4758  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Gpio_hal.c.o
     文件       16154  2018-12-13 07:54  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Isr_dri.c.o
     文件        8516  2018-01-22 10:14  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Rti_dri.c.o
     文件        5793  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Start12.c.o
     文件       10316  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\Tim_dri.c.o
     文件        9496  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\datapage.c.o
     文件       10516  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\main.c.o
     文件      160265  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\mc9s12g128.c.o
     文件       10164  2018-01-22 10:14  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\objectCode\tick.c.o
     文件      994546  2018-12-13 07:54  S12G128_CAN_WakeUp_Interrupt\M4DCM_Data\Standard\TargetDataWindows.tdt
     文件        1066  2018-01-19 15:44  S12G128_CAN_WakeUp_Interrupt\OpenSourceBDM.ini
     目录           0  2018-12-13 07:44  S12G128_CAN_WakeUp_Interrupt\Sources\
     目录           0  2018-12-13 07:44  S12G128_CAN_WakeUp_Interrupt\Sources\App\
     目录           0  2018-12-13 07:44  S12G128_CAN_WakeUp_Interrupt\Sources\App\inc\
     文件        1416  2018-12-13 07:52  S12G128_CAN_WakeUp_Interrupt\Sources\App\inc\USER.h
     文件        3149  2018-12-13 07:53  S12G128_CAN_WakeUp_Interrupt\Sources\App\main.c
     目录           0  2018-12-13 07:56  S12G128_CAN_WakeUp_Interrupt\Sources\App\src\
     目录           0  2018-12-13 07:44  S12G128_CAN_WakeUp_Interrupt\Sources\Dri\
............此处省略59个文件信息

评论

共有 条评论