. , .
:/* Governed by MIT license * made by ozforester * =============== * enable XO fanout * and bypass it * to clk0 * =============== * 5351 i2c connection * wire scl sda * port pc5 pc4 * uno a5 a4 * mega 32 33 * ============== */ #include <stdint.h> #define MULT 2 /* i2c delays multiplier*/ #define SDA2 PC4 #define SCL2 PC5 void setup(void){ twi_init2(); delay(100); send_reg( 187 , 64 ); // enable crystal fanout // others are satisfied after power reset } void loop ( void ){} /* * S I 5 3 5 1 A */ #define SI5351 0x60 void send_reg(uint8_t reg, uint8_t data) { twi_start2(); twi_write_byte2((SI5351<<1)&0b11111110); twi_write_byte2(reg); twi_write_byte2(data); twi_stop2(); } /* * SW I2C */ #define rls2(pin) DDRC &= ~(1<<pin); PORTC |= (1<<pin); #define pdn2(pin) PORTC &= ~(1<<pin); DDRC |= (1<<pin); #define in2(pin) (PINC & (1<<pin)) void twi_delay2(uint8_t d){ for( uint8_t i=0 ; i < (d * MULT); i++); } void twi_init2(void){ // free rls2(SCL2); rls2(SDA2); } void twi_start2(void){ twi_delay2(10); rls2(SDA2); twi_delay2(10); rls2(SCL2); twi_delay2(10); pdn2(SDA2); twi_delay2(4); pdn2(SCL2); twi_delay2(1); } void twi_stop2(void){ twi_delay2(10); rls2(SCL2); twi_delay2(10); rls2(SDA2); twi_delay2(4); } void twi_write_byte2( uint8_t twi_byte ){ for( uint8_t i = 0; i < 8; i++ ){ twi_delay2(1); if(twi_byte&0b10000000) {rls2(SDA2);} else { pdn2(SDA2);} twi_delay2(1); rls2(SCL2); twi_delay2(3); pdn2(SCL2); twi_byte <<= 1; } twi_delay2(1); // pass ack rls2(SDA2); twi_delay2(1); rls2(SCL2); twi_delay2(3); pdn2(SCL2); twi_delay2(1); pdn2(SDA2); twi_delay2(1); }
, reg_187 - Fanout Enable. NT7S, 4 . : -> CLK0.
- ?
: 1 (: 0 , : 1)