- UID
- 187937
- 性别
- 男
|
#include /* common defines and macros */
#include /* derivative information */
#include "system_init.h"
#include "sci0_tx_check.h"
#include "porth_init.h"
#include "pwm_init.h"
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
#define row_num 30
#define line_num 50
word pacbcnt;
word accmid,scicnt;
byte pacflag;
//byte scihigh,scilow;
byte sci[100];
byte cnt0;
void main(void)
{
DisableInterrupts;
system_init(); //init system
porth_init(); //init port h bit0 interrupt
pwm_init();
DDRB=0xff;
PWMDTY1=100;//init duty cycle is 50%
PWME_PWME1=1;//enable the speed motor pwm
///////////////////////////////////////////////////////////////////////
TIOS=0x00; //all pin input
TCTL4=0x02; //catch the falling edge
DLYCT=0x00; //no delay
PBCTL_PBEN=1; //enable the pacB
// PBFLG_PBOVF=1; //clear the overflow flag
///////////////////////////////////////////////////////////////////////
PIEH_PIEH0=1; //enable the port h bit0 interrupt(field interrupt)
pacbcnt=0;
scicnt=0;
pacflag=0;
EnableInterrupts;
//for(;;)
//{
while(pacflag==0);
{
SciInit();
for(cnt0=0;cnt0<3;cnt0++)
SciTx(sci[cnt0]);
}
// }
}
//************************PORTH INTERRUPT**************************//
#pragma CODE_SEG __NEAR_SEG NON_BANKED //the new field start
interrupt void porth(void)
{
PIFH_PIFH0=1; //clear the port h bit0 interrupt flag
pacbcnt=PACN10;
sci[scicnt]=(byte)pacbcnt;
scicnt++;
if(scicnt>=3)
{
pacflag=1;
scicnt=0;
PIEH_PIEH0=0;
}
}
#pragma CODE_SEG DEFAULT
//*****************************************************************//
|
|