Serial monitor freezing :: Arduino Uno Rev 3

Hi all,

I am working with Arduino Uno, and I am trying to print clock in serial monitor.
In loop function (in Arduino sketch) I have a function, which calls another funtction, which prints clock in serial monitor.

void loop() {
  read_clock();
 }
void read_clock(){
uint16_t cas_blok; 
uint16_t minute_stare=50000; //never reached
uint8_t odmik;  

if(analiziraj_RDS_bloke()==0x4A){

    odmik = (blok_D)& 0x3F; 
    cas_blok = (blok_D >> 6) & 0x3F; 
    cas_blok = cas_blok + 60 * (((blok_C & 0x0001) << 4) | ((blok_D >> 12) & 0x0F)); //minute so v bloku D, ure pa v bloku D, ter deloma bloku C
		
	if(minute_stare != cas_blok) {
	
		minute_stare=cas_blok;
		if (odmik & 0x20) { //preverimo ali je odmik pozitiven ali negativen
			cas_blok = cas_blok - 30 * (odmik & 0x1F);
		}
		else {
			cas_blok = cas_blok + 30 * (odmik & 0x1F);
		}
		Serial.print("Ura: "); 
		if(cas_blok/60>=10){
		Serial.print(cas_blok/60);
			
		}
		else {
		Serial.print('0'); 
		Serial.print(cas_blok/60);
			
		}
		Serial.print(':'); 
		if((cas_blok %60)>=10) {
		Serial.println(cas_blok % 60);
			
		}
		else {
			Serial.print('0'); 
			Serial.println(cas_blok % 60);
		
		}
	}
}

}

Clock is obtained from RDS blocks.
The function analiziraj_RDS_bloke() just returns which RDS group (0A-15B) is now the turn, because just 4A group has a clock…
blok_A, blok_B, blok_C and blok_D are global variables uint16_t type, because registers are 16bit.

So, when we have 4A group available, I calculate clock from registers and write it in the Arduino serial monitor with serial.print function.
The problem is, that the serial monitor freeze after some (random) time, and I dont know why. I tried to change baud rate from 9600 (default) to slower and faster speed, but the problem is still here. I tried to use Putty instead of Arduino Serial monitor, but the problem is in Putty also.

I use Arduino Uno Rev 3 and Arduino IDE 1.6.1.

I really don’t know where is the problem, and need your help.

Thanks!

I tried to use Putty instead of Arduino Serial monitor, but the problem is in Putty also.

Clearly, you are wrong. The problem is not with the device receiving the data. The problem is with the device sending the data.

Without seeing ALL of your code, there isn't a snowball's chance in hell of helping you.

Hi,

In setup function I have:

Serial.begin(9600);
Serial.println(“Zdravo!”);
and a function for initialize RDA5807M.

Here is all my code for decode RDS:

//RDS decoder
#include <arduino.h>
#include <wire.h>
#include <FM_RDA5807M.h>
#define RDA5807M_RDSR 0x8000 //RDS ready :: 0=No RDS group ready, 1=New RDS group ready

uint16_t vsebina_registrov_seznam[16];
uint16_t blok_A, blok_B, blok_C, blok_D; 

uint16_t analiziraj_RDS_bloke(){
      uint16_t RDSskupina;
      uint16_t nova_vsebina_bloka;

      Wire.requestFrom (0x10, 2);
      vsebina_registrov_seznam[0x0A] = izvedi_branje(); 
      Wire.endTransmission();

      if (vsebina_registrov_seznam[0x0A] & RDA5807M_RDSR) { //if RDS is available
 
            Wire.beginTransmission(0x11);     //address for random access           
            Wire.write(RDA5807M_RDSA_register);                    
            Wire.endTransmission();                         
     
            Wire.requestFrom(0x11, 8, 1);                 
 
            nova_vsebina_bloka=izvedi_branje();
            if(nova_vsebina_bloka != vsebina_registrov_seznam[0x0C] ) { //if we have new data
                     vsebina_registrov_seznam[0x0C] = nova_vsebina_bloka;
 }
            nova_vsebina_bloka=izvedi_branje();
            if(nova_vsebina_bloka != vsebina_registrov_seznam[0x0D] ) {//if we have new data
                     vsebina_registrov_seznam[0x0D] = nova_vsebina_bloka;
 }
            nova_vsebina_bloka=izvedi_branje();
            if(nova_vsebina_bloka != vsebina_registrov_seznam[0x0E] ) {//if we have new data
                     vsebina_registrov_seznam[0x0E] = nova_vsebina_bloka;
 }
            nova_vsebina_bloka=izvedi_branje();
            if(nova_vsebina_bloka != vsebina_registrov_seznam[0x0F] ) {//if we have new data
                    vsebina_registrov_seznam[0x0F] = nova_vsebina_bloka;
 }
}

blok_A = vsebina_registrov_seznam[0x0C];
blok_B = vsebina_registrov_seznam[0x0D];
blok_C = vsebina_registrov_seznam[0x0E];
blok_D = vsebina_registrov_seznam[0x0F];

//sledi najprej določitev skupine
RDSskupina=0x0A | (((blok_B & 0xF000) >> 8) | ((blok_B & 0x0800) >> 11)); //premaknemo bite na drugo mesto z desne

return RDSskupina;
}


void read_clock(){
uint16_t cas_blok; 
uint16_t minute_stare=50000; //never reached
uint8_t odmik;  

if(analiziraj_RDS_bloke()==0x4A){

    odmik = (blok_D)& 0x3F; 
    cas_blok = (blok_D >> 6) & 0x3F; 
    cas_blok = cas_blok + 60 * (((blok_C & 0x0001) << 4) | ((blok_D >> 12) & 0x0F)); //minute so v bloku D, ure pa v bloku D, ter deloma bloku C
 
 if(minute_stare != cas_blok) {
 
 minute_stare=cas_blok;
 if (odmik & 0x20) { //preverimo ali je odmik pozitiven ali negativen
 cas_blok = cas_blok - 30 * (odmik & 0x1F);
 }
 else {
 cas_blok = cas_blok + 30 * (odmik & 0x1F);
 }
 Serial.print("Ura: "); 
 if(cas_blok/60>=10){
 Serial.print(cas_blok/60);
 
 }
 else {
 Serial.print('0'); 
 Serial.print(cas_blok/60);
 
 }
 Serial.print(':'); 
 if((cas_blok %60)>=10) {
 Serial.println(cas_blok % 60);
 
 }
 else {
 Serial.print('0'); 
 Serial.println(cas_blok % 60);
 
 }
 }
}

}


uint16_t izvedi_branje(void){
 uint8_t zgornji_bajt = Wire.read();
 uint8_t spodnji_bajt = Wire.read();
 return (zgornji_bajt*256+spodnji_bajt);
}

We can find a clock in block D and one bit in block C also. This can be seen on this picture:

The problem is that RDS clock is very unpredictiable. Specially at the evening and overnight, the data is correct. During the day, I receive everything…

I think, here is not reset, because the welcome text (in setup function) does not appear again.

In my country, RDS is available on some (not on all) FM radio stations. It is located on 57kHz (sub carrier) on MPX specter.

I am looking in datasheet (which is I think uncomplited: http://www.seeedstudio.com/wiki/images/8/88/RDA5807M_datasheet_v1.1.pdf), and I see, that, RDA has some registers to check, how many errors are in the blocks...I will try to use this. I will make a limit for incoming data too.

Thanks for your help!

Hi Vaclav.

Yes, I am from Slovenia.

The timing data comes once per minute (in the first second of the full minute), so you must wait whole minute for them. The interesting is, what can I see, in the Slovenia, we are not transmitting offset and UTC time (look in the my attachment up) separately, but we are transmiting local time directly on place, where must be UTC time.

I am using RDA5807M, which has I2C comunication with three adresses (0x10 for sequential access, 0x11 for random and 0x60 which works as TEA5767 mode). Audio is realy very clear from this FM receiver...

For antenna I'm using a piece of wire (lambda/4 ~ 0.8m)

Thanks!