The C500 microcontroller family usually provides only one on-chip synchronous serialchannel (SSC). If a second SSC is required, an emulation of the missing interface mayhelp to avoid an external hardware solution with additional electronic components.The solution presented in this paper and in the attached source files emulates the mostimportant SSC functions by using optimized SW routines with a performance up to 25KBaud in Slave Mode with half duplex transmission and an overhead less than 60% atSAB C513 with 12 MHz. Due to the implementation in C this performance is not the limitof the chip. A pure implementation in assembler will result in a strong reduction of theCPU load and therefore increase the maximum speed of the interface. In addition,microcontrollers like the SAB C505 will speed up the interface by a factor of two becauseof an optimized architecture compared with the SAB C513.Moreover, this solution lays stress on using as few on-chip hardware resources aspossible. A more excessive consumption of those resources will result in a highermaximum speed of the emulated interface.Due to the restricted performance of an 8 bit microcontroller a pin compatible solution isprovided only; the internal register based programming interface is replaced by a set ofsubroutine calls.The attached source files also contain a test shell, which demonstrates how to exchangeinformation between an on-chip HW-SSC and the emulated SW-SSC via 5 external wiresin different operation modes. It is based on the SAB C513 (Siemens 8 bit microcontroller).A table with load measurements is presented to give an indication for the fraction of CPUperformance required by software for emulating the SSC.
标签: synchronous Emulating serial
上传时间: 2014-01-31
上传用户:z1191176801
This application note shows how to write an Inter Integrated Circuit bus driver (I²C) for the Philips P90CL301micro-controller.It is not only an example of writing a driver, but it also includes a set of application interface software routines toquickly implement a complete I²C multi-master system application.For specific applications the user will have to make minimal changes in the driver program. Using the drivermeans linking modules to your application software and including a header-file into the application sourceprograms. A small example program of how to use the driver is listed.The driver supports i.a. polled or interrupt driven message handling, slave message transfers and multi-mastersystem applications. Furthermore, it is made suitable for use in conjunction with real time operating systems, likepSOS+.
上传时间: 2013-11-23
上传用户:weixiao99
The XA-S3 is a member of Philips Semiconductors’ XA (eXtended Architecture) family of high performance 16-bit single-chip Microcontrollers. The XA-S3 combines many powerful peripherals on one chip. Therefore, it is suited for general multipurpose high performance embedded control functions.One of the on-chip peripherals is the I2C bus interface. This report describes worked-out driver software (written in C) to program / use the I2C interface of the XA-S3. The driver software, together with a demo program and interface software routines offer the user a quick start in writing a complete I2C - XAS3 system application.
上传时间: 2013-11-10
上传用户:liaofamous
《现代微机原理与接口技术》实验指导书 TPC-H实验台C语言版 1.实验台结构1)I / O 地址译码电路如上图1所示地址空间280H~2BFH共分8条译码输出线:Y0~Y7 其地址分别是280H~287H、288H~28FH、290H~297H、298H~29FH、2A0H~2A7H、2A8H~2AFH、2B0H~2B7H、2B8H~2BFH,8根译码输出线在实验台I/O地址处分别由自锁紧插孔引出供实验选用(见图2)。 2) 总线插孔采用“自锁紧”插座在标有“总线”区引出数据总线D7~D0;地址总线A9~A0,读、写信号IOR、IOW;中断请求信号IRQ ;DMA请求信号DRQ1;DMA响应信号DACK1 及AEN信号,供学生搭试各种接口实验电路使用。3) 时钟电路如图-3所示可以输出1MHZ 2MHZ两种信号供A/D转换器定时器/计数器串行接口实验使用。图34) 逻辑电平开关电路如图-4所示实验台右下方设有8个开关K7~K0,开关拨到“1”位置时开关断开,输出高电平。向下打到“0”位置时开关接通,输出低电平。电路中串接了保护电阻使接口电路不直接同+5V 、GND相连,可有效地防止因误操作误编程损坏集成电路现象。图 4 图 55) L E D 显示电路如图-5所示实验台上设有8个发光二极管及相关驱动电路(输入端L7~L0),当输入信号为“1” 时发光,为“0”时灭6) 七段数码管显示电路如图-6所示实验台上设有两个共阴极七段数码管及驱动电路,段码为同相驱动器,位码为反相驱动器。从段码与位码的驱动器输入端(段码输入端a、b、c、d、e、f、g、dp,位码输入端s1、 s2)输入不同的代码即可显示不同数字或符号。
上传时间: 2013-11-22
上传用户:sssnaxie
串行编程器源程序(Keil C语言)//FID=01:AT89C2051系列编程器//实现编程的读,写,擦等细节//AT89C2051的特殊处:给XTAL一个脉冲,地址计数加1;P1的引脚排列与AT89C51相反,需要用函数转换#include <e51pro.h> #define C2051_P3_7 P1_0#define C2051_P1 P0//注意引脚排列相反#define C2051_P3_0 P1_1#define C2051_P3_1 P1_2#define C2051_XTAL P1_4#define C2051_P3_2 P1_5#define C2051_P3_3 P1_6#define C2051_P3_4 P1_7#define C2051_P3_5 P3_5 void InitPro01()//编程前的准备工作{ SetVpp0V(); P0=0xff; P1=0xff; C2051_P3_5=1; C2051_XTAL=0; Delay_ms(20); nAddress=0x0000; SetVpp5V();} void ProOver01()//编程结束后的工作,设置合适的引脚电平{ SetVpp5V(); P0=0xff; P1=0xff; C2051_P3_5=1; C2051_XTAL=1;} BYTE GetData()//从P0口获得数据{ B_0=P0_7; B_1=P0_6; B_2=P0_5; B_3=P0_4; B_4=P0_3; B_5=P0_2; B_6=P0_1; B_7=P0_0; return B;} void SetData(BYTE DataByte)//转换并设置P0口的数据{ B=DataByte; P0_0=B_7; P0_1=B_6; P0_2=B_5; P0_3=B_4; P0_4=B_3; P0_5=B_2; P0_6=B_1; P0_7=B_0;} void ReadSign01()//读特征字{ InitPro01(); Delay_ms(1);//----------------------------------------------------------------------------- //根据器件的DataSheet,设置相应的编程控制信号 C2051_P3_3=0; C2051_P3_4=0; C2051_P3_5=0; C2051_P3_7=0; Delay_ms(20); ComBuf[2]=GetData(); C2051_XTAL=1; C2051_XTAL=0; Delay_us(20); ComBuf[3]=GetData(); ComBuf[4]=0xff;//----------------------------------------------------------------------------- ProOver01();} void Erase01()//擦除器件{ InitPro01();//----------------------------------------------------------------------------- //根据器件的DataSheet,设置相应的编程控制信号 C2051_P3_3=1; C2051_P3_4=0; C2051_P3_5=0; C2051_P3_7=0; Delay_ms(1); SetVpp12V(); Delay_ms(1); C2051_P3_2=0; Delay_ms(10); C2051_P3_2=1; Delay_ms(1);//----------------------------------------------------------------------------- ProOver01();} BOOL Write01(BYTE Data)//写器件{//----------------------------------------------------------------------------- //根据器件的DataSheet,设置相应的编程控制信号 //写一个单元 C2051_P3_3=0; C2051_P3_4=1; C2051_P3_5=1; C2051_P3_7=1; SetData(Data); SetVpp12V(); Delay_us(20); C2051_P3_2=0; Delay_us(20); C2051_P3_2=1; Delay_us(20); SetVpp5V(); Delay_us(20); C2051_P3_4=0; Delay_ms(2); nTimeOut=0; P0=0xff; nTimeOut=0; while(!GetData()==Data)//效验:循环读,直到读出与写入的数相同 { nTimeOut++; if(nTimeOut>1000)//超时了 { return 0; } } C2051_XTAL=1; C2051_XTAL=0;//一个脉冲指向下一个单元//----------------------------------------------------------------------------- return 1;} BYTE Read01()//读器件{ BYTE Data;//----------------------------------------------------------------------------- //根据器件的DataSheet,设置相应的编程控制信号 //读一个单元 C2051_P3_3=0; C2051_P3_4=0; C2051_P3_5=1; C2051_P3_7=1; Data=GetData(); C2051_XTAL=1; C2051_XTAL=0;//一个脉冲指向下一个单元//----------------------------------------------------------------------------- return Data;} void Lock01()//写锁定位{ InitPro01();//先设置成编程状态//----------------------------------------------------------------------------- //根据器件的DataSheet,设置相应的编程控制信号 if(ComBuf[2]>=1)//ComBuf[2]为锁定位 { C2051_P3_3=1; C2051_P3_4=1; C2051_P3_5=1; C2051_P3_7=1; Delay_us(20); SetVpp12V(); Delay_us(20); C2051_P3_2=0; Delay_us(20); C2051_P3_2=1; Delay_us(20); SetVpp5V(); } if(ComBuf[2]>=2) { C2051_P3_3=1; C2051_P3_4=1; C2051_P3_5=0; C2051_P3_7=0; Delay_us(20); SetVpp12V(); Delay_us(20); C2051_P3_2=0; Delay_us(20); C2051_P3_2=1; Delay_us(20); SetVpp5V(); }//----------------------------------------------------------------------------- ProOver01();} void PreparePro01()//设置pw中的函数指针,让主程序可以调用上面的函数{ pw.fpInitPro=InitPro01; pw.fpReadSign=ReadSign01; pw.fpErase=Erase01; pw.fpWrite=Write01; pw.fpRead=Read01; pw.fpLock=Lock01; pw.fpProOver=ProOver01;}
上传时间: 2013-11-12
上传用户:gut1234567
用C 语言来开发单片机系统软件最大的好处是编写代码效率高、软件调试直观、维护升级方便、代码的重复利用率高、便于跨平台的代码移植等等,因此C 语言编程在单片机系统设计中已得到越来越广泛的运用。针对PIC 单片机的软件开发,同样可以用C 语言实现。但在单片机上用C 语言写程序和在PC 机上写程序绝对不能简单等同。现在的PC 机资源十分丰富,运算能力强大,因此程序员在写PC 机的应用程序时几乎不用关心编译后的可执行代码在运行过程中需要占用多少系统资源,也基本不用担心运行效率有多高。写单片机的C 程序最关键的一点是单片机内的资源非常有限,控制的实时性要求又很高,因此,如果没有对单片机体系结构和硬件资源作详尽的了解,以笔者的愚见认为是无法写出高质量实用的C 语言程序。这就是为什么前面所有章节中的的示范代码全部用基础的汇编指令实现的原因,希望籍此能使读者对PIC 单片机的指令体系和硬件资源有深入了解,在这基础之上再来讨论C 语言编程,就有水到渠成的感觉。本书围绕中档系列PIC 单片机来展开讨论,Microchip 公司自己没有针对中低档系列PIC单片机的C 语言编译器,但很多专业的第三方公司有众多支持PIC 单片机的C 语言编译器提供,常见的有Hitech、CCS、IAR、Bytecraft 等公司。其中笔者最常用的是Hitech 公司的PICC编译器,它稳定可靠,编译生成的代码效率高,在用PIC 单片机进行系统设计和开发的工程师群体中得到广泛认可。其正式完全版软件需要购置,但在其网站上有限时的试用版供用户评估。另外,Hitech 公司针对广大PIC 的业余爱好者和初学者还提供了完全免费的学习版PICC-Lite 编译器套件,它的使用方式和完全版相同,只是支持的PIC 单片机型号限制在PIC16F84、PIC16F877 和PIC16F628 等几款。这几款Flash 型的单片机因其所具备的丰富的片上资源而最适用于单片机学习入门,因此笔者建议感兴趣的读者可从PICC-Lite 入手掌握PIC 单片机的C 语言编程。
上传时间: 2013-11-17
上传用户:aa54
HI-TECH PICC C 的使用说明. 这里我们只讲述了PICC C 与标准C 的不同,它不是一本C 语言的教程, 并且我们假定你有C 语言的基础. 为了对PIC 单片机有更好的支持,PICC 在标准C 的基础上作了一些扩充: 定义I/O 函数,以便在你的硬件系统中使用<stdio.h>中定义的函数。 用C 语言编写中断服务程序 用C 语言编写I/O 操作程序 C 语言与汇编语言间的接口1-1 与标准C 的不同PICC 只在一处与标准C 不同:函数的重入。因为PIC 单片机的寄存器及堆栈有限,所以PICC 不支持可重入函数。1-2 支持的PIC 芯片PICC 支持很多PIC 单片机,支持PIC 单片机的类型在LIB 目录下的picinfo.ini文件中有定义。1-3 PICC 包含一些标准库1-4 PICC 编译器可以输出一些格式的目标文件,缺省设置为输出Bytecraft 的'COD'格式和 Intel 的'HEX'格式。你可以用表1-1 中的命令来指定输出格式。
上传时间: 2013-10-10
上传用户:781354052
U盘IC1114的电路图和C语言源程序
上传时间: 2013-12-17
上传用户:hanli8870
微型打印机的C语言源程序:微型打印机的C51源程序#define uchar unsigned char#define uint unsigned int#include <reg52.h>#include <stdio.h>#include <absacc.h>#include <math.h>#include <string.h>#include <ctype.h>#include <stdlib.h>#define PIN XBYTE[0x8000]#define POUT XBYTE[0x9000]sbit PRINTSTB =P1^6;sbit DOG=P1^7;bdata char pin&#118alue;sbit PRINTBUSY=pin&#118alue^7;sbit PRINTSEL =pin&#118alue^6;sbit PRINTERR =pin&#118alue^5;sbit PRINTACK =pin&#118alue^4; void PrintString(uchar *String1,uchar *String2);void initprint(void);void print(uchar a); void initprint(void) //打印机初始化子程序 { pin&#118alue=PIN; if((PRINTSEL==1)&&(PRINTERR==1)) { print(0x1b); print(0x40); print(0x1b); print(0x38); print(0x4); }}void print(uchar a) //打印字符a{ pin&#118alue=PIN; if((PRINTSEL==0)||(PRINTERR==0)) return; for(;;) { DOG=~DOG; pin&#118alue=PIN; if(PRINTBUSY==0) break; } DOG=~DOG; POUT=a; PRINTSTB=1; PRINTSTB=1; PRINTSTB=1; PRINTSTB=1; PRINTSTB=0; PRINTSTB=0; PRINTSTB=0; PRINTSTB=0; PRINTSTB=1;}void PrintString(uchar *String) //打印字符串后回车{ uchar CH; for (;;) { DOG=~DOG; CH=*String; if (CH==0) { print(0x0d); break; } print(CH); String++; } initprint();}
上传时间: 2013-10-18
上传用户:hasan2015
AVR系统单片机C语言编程与应用实例针对Atmel公司的AVR系列单片机和ImageCraft公司的ICC AVR开发环境,详细地介绍了AT90LS8535的C语言程序设计。全书共有13章,其内容既涉及到了单片机的结构原理、指令系统、内容资源和外部功能扩展,又包含了单片机的编程工具——ICC AVR C编程器的数据类型、控制流、函数和指针等。本书的特点是:深入浅出,从最基本的概念开始,循序渐进地讲解单片机的应用开发;列举了大量实例,使读者能从实际应用中掌握单片机的开发与应用技术。本书适合作为从事单片机开发人员的参考用书。
上传时间: 2013-10-19
上传用户:xz85592677