DatasheetQ Logo
Electronic component search and free download site. Transistors,MosFET ,Diode,Integrated circuits

AN1045 查看數據表(PDF) - STMicroelectronics

零件编号
产品描述 (功能)
生产厂家
AN1045 Datasheet PDF : 16 Pages
1 2 3 4 5 6 7 8 9 10 Next Last
ST7 S/W IMPLEMENTATION OF I2C BUS MASTER
/* MODEL => [static] type_name var_name; or #define
*/
void delay (unsigned char time)
{
#ifdef __HIWARE__
asm
{
nop
/* Time is stored on the Accumulator automatically */
again: DEC A /* When the function is called.
*/
JRNE again
/* (15+6*time) clock cycles
*/
}
#else
#ifdef __CSMC__
{
_asm ("nop");
_asm("again: DEC A");
_asm(" JRNE again");
}
#endif
#endif
}
/*--------------------------------------------------------------------------
ROUTINE NAME : I2Cm_Start
INPUT/OUTPUT : None.
DESCRIPTION : Generates I2C-Bus Start Condition.
COMMENTS :
--------------------------------------------------------------------------*/
void I2Cm_Start (void)
{
ClrBit(PADDR,SDA);
/* Configure SDA and SCL as floating input to have a high state */
ClrBit(PADDR,SCL);
delay(10);
SetBit(PADDR,SDA);
/* Configure SDA as output open drain to have a low state */
delay(4);
/* Waits 39 cycles=4.875µs at a Fcpu=8MHz to keep the high state on SCL */
SetBit(PADDR,SCL);
/* Configure SCL as output open drain to have a low state */
delay(6); /* Delay to wait after a START
*/
}
/*--------------------------------------------------------------------------
ROUTINE NAME : I2Cm_Stop
9/16

Share Link: 

datasheetq.com  [ Privacy Policy ]Request Datasheet ] [ Contact Us ]