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

📄 debugger.ini

📁 this application program demonstrate programming and simulation of the on-chip CAN (controller area
💻 INI
字号:
/* ========================DEBUGGER.INI=============================
 * Contains debug functions for the sample CAN project (App_Nt 167).
 *
 * - PressSwitch enables simulation of buttons on memory mapped I/O
 * - CANMessage  prints message information of send messages
 * - SendInfo    sends 8Byte messages on a arbitrary ID
 * - SimTraffic  simulates sending of messages in a short interval
 *
 * =================================================================
 */


/* 
 * Simulate a 0.1 Second Click on Switch I/O Port (for S1 & S2) 
 */
SIGNAL void PressSwitch (unsigned char v)  {
  unsigned char cx;

  S0OUT = v;                     // set I/O Port value for switch v
  swatch (0.1);                  // press switch for 0.1 seconds
}


/*
 * Define Buttons for the toolbox with presets for PressSwitch
 */
define button "Send S1 Command",    "PressSwitch (1)" 
define button "Send S2 Command",    "PressSwitch (2)"
define button "Send S1+S2 Command",  "PressSwitch (3)"


/* 
 * Print the last message sent by the controller 
 */
FUNC void CANmessage (void) {
  switch (CAN1OUT) {
    case 1: printf("\nSend Message (11-bit ID=%04X)", CAN1ID);    break;
    case 2: printf("\nSend Message (29-bit ID=%08X)", CAN1ID);    break;
    case 3: printf("\nRequest Message (11-bit ID=%04X)", CAN1ID); return;
    case 4: printf("\nRequest Message (29-bit ID=%08X)", CAN1ID); return;
  }
  printf("\nMessage Length %d, Data: ", CAN1L);
  printf("%02X %02X %02X %02X ", CAN1B0, CAN1B1, CAN1B2, CAN1B3);
  printf("%02X %02X %02X %02X\n", CAN1B4, CAN1B5, CAN1B6, CAN1B7);
}


/* 
 * Set Breakpoint on CAN Output VTREG
 */
BS WRITE CAN1OUT, 1, "CANmessage()" 


/* 
 * Send Information on any ID
 */
FUNC void SendInfo (unsigned long id,    // message ID
                    unsigned char len,   // message length
                    unsigned char val) { // 1. value byte
  CAN1ID = id;      // Set VTREG that keeps next ID
  CAN1L  = len;     // Set VTREG with message length
  CAN1B0 = val;     // Set the data registers
  CAN1B1 = val+1;
  CAN1B2 = val+2;
  CAN1B3 = val+3;
  CAN1B4 = val+4;
  CAN1B5 = val+5;
  CAN1B6 = val+6;
  CAN1B7 = val+7;
  CAN1IN = 2;      // Send message to simulated controller
}


/* 
 * Send 5 messages in short intervals on ID 103h 
 */
SIGNAL void SimTraffic (void) {
  int i;
  for (i=0; i<=5; i++) {
    SendInfo(0x103,8,'0'+(i*8));      // Send CAN message on ID 103h
    swatch(0.00025);                  // wait 0.00025sec before next message is send
  }
}


/*
 * Define Buttons for the toolbox for easy access to SendInfo and SimTraffic
 */
define button "Receive S1+S2 Command",  "SendInfo(0x101,1,0x30)"
define button "Receive Button Reset", "SendInfo(0x101,1,0x00)"
define button "Send Remote Frame",   "SendInfo(0x104,8,0x00)"
define button "Simulate Reception Traffic", "SimTraffic()"





⌨️ 快捷键说明

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