FX2 Crash after writing in struct

I use a Cypress Fx2. It's no problem to write a value to dcf.sekunde but if i set dcf.minute to 0 or such a other value, the controller will stops/crash.

I'm not sure if the struct definition is correct or if i must reserver a address block for it. i hope someone can help me.

Thanks

Sorry for my bad English.

FX2_DCF-Clock.h

 typedef xdata struct signal {
unsigned char sekunde;
unsigned char minute;
unsigned char stunde;
unsigned char tag;
unsigned char wochentag;
unsigned char monat;
unsigned char jahr;
unsigned char synkro;
unsigned int  fehler_zaehler;
}tdcf;

extern tdcf dcf;

.

FX2_DCF-Clock.c

 txdata tdcf dcf;
 if(dcf.sekunde>59)
        {
                dcf.synkro=KEINSYNK;
                dcf.sekunde=0;

crash/stop

                dcf.minute=0;
                dcf.stunde=0;
        }

Parents
  • "I'm not sure if the struct definition is correct ..."

    Since types do not occupy memory, it's not very meaningful for them to have a memory space specifier. It's more meaningful for allocated data objects to have the memory space specifier.

    FX2_DCF-Clock.h

    typedef struct signal {
        unsigned char sekunde;
        unsigned char minute;
        unsigned char stunde;
        unsigned char tag;
        unsigned char wochentag;
        unsigned char monat;
        unsigned char jahr;
        unsigned char synkro;
        unsigned int  fehler_zaehler;
    }tdcf;
    
    extern tdcf xdata dcf;
    

    FX2_DCF-Clock.c

    tdcf xdata dcf;
    

    Your typedef does two things; defines 'struct signal' and defines a new type (alias) for 'struct signal' named 'tdcf'. The structure tag ('signal') and the typedef name 'tdcf' are separate things. Combining the way you have done is legitimate.

Reply
  • "I'm not sure if the struct definition is correct ..."

    Since types do not occupy memory, it's not very meaningful for them to have a memory space specifier. It's more meaningful for allocated data objects to have the memory space specifier.

    FX2_DCF-Clock.h

    typedef struct signal {
        unsigned char sekunde;
        unsigned char minute;
        unsigned char stunde;
        unsigned char tag;
        unsigned char wochentag;
        unsigned char monat;
        unsigned char jahr;
        unsigned char synkro;
        unsigned int  fehler_zaehler;
    }tdcf;
    
    extern tdcf xdata dcf;
    

    FX2_DCF-Clock.c

    tdcf xdata dcf;
    

    Your typedef does two things; defines 'struct signal' and defines a new type (alias) for 'struct signal' named 'tdcf'. The structure tag ('signal') and the typedef name 'tdcf' are separate things. Combining the way you have done is legitimate.

Children
More questions in this forum