top of page

ATmega128 TWI 초기화

  • 작성자 사진: 홍근 정
    홍근 정
  • 2015년 11월 4일
  • 1분 분량

void Baud_Calculate(long Hz){ // calculate bitrate division TWBR = (byte)(0.5f*((_FCPU_/Hz)-16)); }

void TWI_Clock_Devide_Init(void) { TWSR = (0<<TWPS1) | (0<<TWPS0); // 1 분주 // TWSR = (0<<TWPS1) | (1<<TWPS0); // 4 분주 // TWSR = (1<<TWPS1) | (0<<TWPS0); // 16 분주 // TWSR = (1<<TWPS1) | (1<<TWPS0); // 64 분주 }

void TWI_Reset(void){ _g_TWI_Rx_Time_Count = _TWI_Rx_TimeOut_;

_g_Rx_TWI_TopCount = 0; _g_Rx_TWI_ButtomCount = 0;

TWI_Clock_Devide_Init(); Baud_Calculate(400000);

TWCR = (1<<TWEN)| (1<<TWIE)|(1<<TWINT)| (1<<TWEA)|(0<<TWSTA)|(0<<TWSTO)| (0<<TWWC); }

 
 
 

Comments


bottom of page