Open radio-miskovice opened 4 years ago
I have a program that initializes CLK0, sets frequency and then it periodically reads device status, and sends some results to Serial.
It appears that even when I remove the Si5351 module, the program still reads some "status" (LOL_A = 0);
Expected behavior I would expect some kind of error, to recognize the device is not present.
Code
#include <Wire.h> #include "si5351.h" /* Si5351 module */ #define VFO SI5351_CLK0 uint64_t vfoFreq = 702130000ULL ; bool vfoOk = false ; Si5351 vfo ; void setup() { uint8_t idev ; uint16_t dw ; // blinker & serial // pinMode( PC13, OUTPUT ); digitalWrite( PC13, LOW ); Serial.begin(115200); delay(10); Serial.println("started."); digitalWrite( PC13, HIGH ); // I2C setup // Wire.setSDA(PB9); // Wire.setSCL(PB8); Wire.begin(); Serial.println("I2C bus on PB8, PB9"); Si5351A initalization Serial.print("Si5351 "); if( checkI2C( 0x60 ) != 0 ) Serial.println("not "); Serial.println("present"); vfoOk = vfo.init(SI5351_CRYSTAL_LOAD_8PF, 0, 0) ; Serial.println( vfoOk ? "VFO OK" : "VFO ??" ); vfo.set_freq( vfoFreq, VFO ); vfo.update_status(); delay(1000); } uint8_t lastPllA = 0xFF ; void loop() { Si5351Status st = vfo.dev_status ; vfo.update_status(); if( st.LOL_A != lastPllA ) { Serial.printf( "VFO PLL A: %i\n", st.LOL_A ); lastPllA = st.LOL_A ; } digitalWrite( PC13, LOW ); vfo.output_enable( VFO, false ); delay( 200 ); readSerial(); } void readSerial() { char text[40] = { 0 }; byte inputSize = 0 ; if( Serial.available() ) { digitalWrite( PC13, HIGH ); delay(100); inputSize = Serial.readBytesUntil( '\n', text, 39 ); if( inputSize ) text[inputSize] = 0; Serial.print( "ECHO: "); Serial.println( text ); delay(65); digitalWrite( PC13, LOW ); } } uint8_t checkI2C( uint8_t addr ) { Wire.beginTransmission( addr ); return Wire.endTransmission(); }
I have a program that initializes CLK0, sets frequency and then it periodically reads device status, and sends some results to Serial.
It appears that even when I remove the Si5351 module, the program still reads some "status" (LOL_A = 0);
Expected behavior I would expect some kind of error, to recognize the device is not present.
Code