beautypg.com

Delta Electronics VFD-M User Manual

Page 106

background image

Chapter 4 Parameters|

Revision May 2008, ME14, SW V3.04

4-71

void main(){

int i;

outportb(PORT+MCR,0x08); /* interrupt enable */

outportb(PORT+IER,0x01); /* interrupt as data in */

outportb(PORT+LCR,(inportb(PORT+LCR) | 0x80));

/* the BRDL/BRDH can be access as LCR.b7==1 */

outportb(PORT+BRDL,12); /* set baudrate=9600, 12=115200/9600*/

outportb(PORT+BRDH,0x00);

outportb(PORT+LCR,0x06); /* set protocol, <7,N,2>=06H

<7,E,1>=1AH, <7,O,1>=0AH

<8,N,2>=07H, <8,E,1>=1BH

<8,O,1>=0BH */

for(i=0;i<=16;i++){

while(!(inportb(PORT+LSR) & 0x20)); /* wait until THR empty */

outportb(PORT+THR,tdat[i]); /* send data to THR */

}

i=0;

while(!kbhit()){

if(inportb(PORT+LSR) & 0x01){ /* b0==1, read data ready */

rdat[i++]=inportb(PORT+RDR); /* read data form RDR */

} } }