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

📄 main.c

📁 Freescale Code Warrior中C的编程
💻 C
字号:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

extern char __SEG_START_SSTACK[];
extern char __SEG_SIZE_SSTACK[];
extern char __SEG_END_SSTACK[];

#define DEBUG_STACK

#ifdef DEBUG_STACK
  #define CHECK_STACK()  \
  __asm("TSX\n  \
  AIX #-3\n \
  PSHX\n \
  PSHH\n \
  LDHX @__SEG_START_SSTACK\n \
  CPHX 1,SP\n \
  BCS +1\n \
  BGND\n \
  PULA\n \
  PULA\n")
#endif


char vfnIncTillFull(char);
void vfnFunction1(void);
void vfnFunction2(void);


void MCU_init(void); /* Device initialization function declaration */

void main(void) {
  /* Uncomment this function call after using Device Initialization
     to use the generated code */
  /* MCU_init(); */
  unsigned char test = 0xF6;
  unsigned int a;


  EnableInterrupts; /* enable interrupts */

  /* include your code here */


  for(;;) {
    __RESET_WATCHDOG(); /* feeds the dog */
    vfnFunction1();
    vfnFunction2();
    vfnFunction1();
    a = vfnIncTillFull(test);
  } /* loop forever */
  /* please make sure that you never leave this function */
}

char vfnIncTillFull(char dato)
{
  #ifdef DEBUG_STACK
    CHECK_STACK();
  #endif
  dato++;
  if(dato==0xFF) {
    return dato;
  } else {
    return vfnIncTillFull(dato);
  }
  
}


void vfnFunction1(void)
{
  volatile char array[16] = { 0 };
  #ifdef DEBUG_STACK
    CHECK_STACK();
  #endif
}


void vfnFunction2(void)
{
  #ifdef DEBUG_STACK
    CHECK_STACK();
  #endif
}

⌨️ 快捷键说明

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