8051 microcontrollers an applications based introduction

Page 115

106 P89C66x microcontroller The P89C664 experiment board had a value of fOSC ¼ 11:0592 MHz. ENS1 STA STO SI AA

enable serial 1 when ¼ 1 enables the I2 C start, used to generate starts, refer to I2 C protocol later stop, used to generate stops, refer to I2 C protocol later serial interrupt assert acknowledge

These last four control bits are very important in the use of the I2 C bus. Table 4.4 Serial clock rates CR2

CR1

CR0

fosc divided by

0 0 0 0 1 1 1 1

0 0 1 1 0 0 1 1

0 1 0 1 0 1 0 1

128 112 96 80 480 60 30 48 (256 reload value Timer 1)

USE OF THE SI BIT SI is usually cleared by software; SI is set when a function completes. Example 4.16 To illustrate the effect of the SI bit consider the following assembly language programs: ; program to send a Start (STA ¼ 1) SETB STA ; set STA ¼ 1 CLR SI ; clear SI LOOP: JNB SI,LOOP ; continually loop until SI ¼ 1, then ; STA will ¼ 1 ; program to send a Stop (STO ¼ 1) SETB STO ; set STO ¼ 1 CLR SI ; clear SI LOOP: JNB SI,LOOP ; continually loop until SI ¼ 1, then ; STO will ¼ 1 ; program to send data e.g.#04h CLR STA ; clear start (STA ¼ 0) MOV S1DAT,#04H ; put hex 4 into s1dat CLR SI ; clear SI LOOP: JNB SI,LOOP ; continually loop until SI ¼ 1, then ; s1dat will contain #04H ; program to set up transmission speed, send a stop, send a start, ; clear SI


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.