📄 main.c
字号:
// ===================================================================
// Macro Functions definitions
// ===================================================================
// The setting in project preference must be checked
// char should be unsigned 8 bit
typedef unsigned char muint8;
typedef unsigned short muint16;
typedef unsigned long muint32;
typedef char mint8;
typedef short mint16;
typedef long mint32;
// To Clear or Set single bits in a byte variable.
#define b_SetBit(bit_ID, varID) (varID |= (muint8)(1<<bit_ID))
#define b_ClearBit(bit_ID, varID) (varID &= ~(muint8)(1<<bit_ID))
#define b_XorBit(bit_ID, varID) (varID ^= (muint8)(1<<bit_ID))
// To Clear or Set single bits in a word(16-bit) variable.
#define w_SetBit(bit_ID, varID) (varID |= (muint16)(1<<bit_ID))
#define w_ClearBit(bit_ID, varID) (varID &= ~(muint16)(1<<bit_ID))
#define w_XorBit(bit_ID, varID) (varID ^= (muint16)(1<<bit_ID))
/* Include shared modules, which are used for whole project */
#include <stdio.h>
#include <time.h>
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "debug.h"
//#include "IO_Map.h"
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC9S08AW60.h> /* include peripheral declarations */
void main(void) {
unsigned short ms;
unsigned short tempcount;
unsigned short tempcount2;
EnableInterrupts; /* enable interrupts */
/* include your code here */
SOPT = 0x00; // Disable COP
// Begin LED/Switch test
PTCDD = 0x10; // set port c as inputs for push button switch input
PTCPE = 0xEF; // enable port c pullups for push button switch operation
PTFDD = 0xFF; // set port f as outputs for LED operation
PTFD = 0x00;
while(1) // If ms still has time left, delay another ms
{
if (PTCD_PTCD2==0x01)
b_ClearBit(0,PTFD);
else
b_SetBit(0,PTFD);
b_SetBit(7,PTFD);
tempcount = 125; // This loop is about 8 instructions
while(tempcount != 0) // 125 loops is 1000 instructions
{
tempcount2 = 125;
while(tempcount2 != 0) // 125 loops is 1000 instructions
tempcount2--;
tempcount--; // Run at 4MHz is 1ms
}
b_ClearBit(7,PTFD);
tempcount = 125; // This loop is about 8 instructions
while(tempcount != 0) // 125 loops is 1000 instructions
{
tempcount2 = 125;
while(tempcount2 != 0) // 125 loops is 1000 instructions
tempcount2--;
tempcount--; // Run at 4MHz is 1ms
}
}
for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
/* please make sure that you never leave this function */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -