📄 main_lms.c
字号:
/*测试F206 / 9月份大板子F206第2版本 */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#define N4 4
#define S8 8
asm("pmst .set 0ffe4h ");
asm("icr .set 0ffech ");
asm("wsgr .set 0fffch ");
asm("sdtr .set 0fff0h ");
asm("sspcr .set 0fff1h ");
asm("adtr .set 0fff4h") ;
asm("aspcr .set 0fff5h");
asm("iosr .set 0fff6h");
asm("brd .set 0fff7h");
asm("tcr .set 0fff8h");
asm("prd .set 0fff9h");
asm("tim .set 0fffah");
asm("ifr .set 0006h");
asm("imr .set 0004h");
asm("greg .set 0005h");
asm("cr8251 .set 8001h");
asm("dr8251 .set 8000h");
int sindata[128]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,
0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000};
extern void lms();
main()
{ int i;
asm(" setc intm "); //清除所有中断
asm(" clrc cnf"); //
asm(" setc xf"); //置位XF
asm(" LDP #0H ");
asm(" nop");
asm(" SPLK #04H,60H");
asm(" NOP");
asm(" OUT 60H,pmst"); // DON=1,PON=0,MP/MC=0
//SARAM in DM at 800h
//微计算机模式,从内部存储器取复位向量
asm(" splk #0e40h,64h");
asm(" nop");
asm(" out 64h,wsgr"); //等待状态产生器控制寄存器
asm(" splk #0000h,greg"); //全局存储器分配寄存器=0,
//数据空间全部分配给局部数据存储器
asm(" nop");
asm(" splk #0000h,60h");
asm(" out 60h,sspcr");
asm(" splk #082fh,63h"); //定时器控制寄存器 TCR中
asm(" nop"); //free=1,soft=0,自由运行
asm(" out 63h,tcr "); //PSC=0000,定时器预分频计数器
//TRB=1,定时器重新加载
//将TDDR中的值加载到PSC,PRD中的值加载到TIM
//TDDR定时器除数寄存器=F
asm(" splk #0efffh,62h"); //定时器周期寄存器=0efffh
asm(" nop");
asm(" out 62h,prd ");
//定时器中断速率TINT=CLOCKOUT1频率/(TDDR+1)(PRD+1)
//设CLOCKOUT1=9.8304*2MHZ,则周期50ms
asm(" splk #0012h,60h"); //ICR中断屏蔽寄存器,开放INT3,屏蔽INT2
asm(" nop");
asm(" out 60h,icr");
asm(" ldp #0h");
asm(" nop");
/*asm(" splk #0c100h,61h");*/
asm(" splk #0e003h,60h"); //io0\io1为输出,测试用
asm(" out 60h,aspcr");
asm(" splk #0003h,61h"); //io0\io1置高
asm(" out 61h,iosr");
asm(" splk #0100h,63h"); //波特率设置brd=CLOCKOUT1频率/(16*所须波特率)
asm(" out 63h,brd "); //假设 所须波特率=4800, CLOCKOUT1频率=9.8304*2MHZ
//brd=0100h
/*asm(" splk #0e100h,61h");*/
/*asm(" splk #0e080h,61h");
asm(" out 61h,aspcr"); */ //复位异步串口
asm(" splk #0000h,62h");
asm(" SPLK #003FH,ifr"); //写1清除所有待决的中断
asm(" SPLK #0026H,imr"); //开读fifo中断
asm(" clrc intm "); //打开总中断
asm(" in 60h,dr8251");
asm(" clrc xf");
/*wpj 于2003/12/17 测试8253,8253分配在数据空间,8253/U2,4分频*/
asm(" LDP #0180H "); //
asm(" splk #0036h,03h"); //
asm(" nop"); //
asm(" nop"); //
asm(" splk #04h,00h"); //
asm(" nop"); //
asm(" nop"); //
asm(" splk #00h,00h"); //
asm(" nop"); //
asm(" nop"); //
/*wpj 于2003/12/17 测试8253,8253分配在数据空间,8253/U2,4分频*/
/*wpj 于2003/12/17 测试8253 方波发生器,8253分配在IO空间,4分频*/
asm(" ldp #0h"); //
asm(" splk #0036h,63h"); // 方式字
asm(" splk #04h,64h"); // 低8位
asm(" splk #00h,65h"); // 高8位
//
asm(" out 63h,0C003h"); // 8253/U2
asm(" nop"); //
asm(" nop"); //
asm(" out 64h,0C000h"); // 低8位
asm(" nop"); //
asm(" nop"); // 高8位
asm(" out 65h,0C000h"); //
asm(" nop"); //
asm(" nop"); //
//
asm(" out 63h,0A003h"); // 8253/U1
asm(" nop"); //
asm(" nop"); //
asm(" out 64h,0A000h"); // 低8位
asm(" nop"); //
asm(" nop"); //
asm(" out 65h,0A000h"); // 高8位
asm(" nop"); //
asm(" nop"); //
/*wpj 于2003/12/17 测试8253 方波发生器,8253分配在IO空间,4分频*/
asm(" splk #0003h,61h");
asm(" splk #0000h,62h");
/***********************begin*****************************/
lms();
/*********************************************************/
while(1)
{
asm(" setc xf"); //测试XF方波
asm(" out 62h,iosr"); //测试 IO0,IO1方波
asm(" nop");
asm(" nop");
asm(" out 61h,iosr");
asm(" clrc xf");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -