# HG changeset patch # User paul # Date 2016-01-26 13:47:58 # Node ID cc5f75e74b54f6015ea362e2bf0c08b7922124d7 # Parent 8fb8ea5be030d6bf3ecf0a62daba282f14b5f21a Snapshot resynchro rewritten, drift is measured one snapshot in two functions related to Cache Control register renamed functions related to Ancillary State Register 16 added (EDAC on register files) diff --git a/header/GscMemoryLPP.hpp b/header/GscMemoryLPP.hpp --- a/header/GscMemoryLPP.hpp +++ b/header/GscMemoryLPP.hpp @@ -106,7 +106,7 @@ static void CCR_faultTolerantScheme() if( (vendorId == VENDORID_GAISLER) & (deviceId ==DEVICEID_LEON3FT) ) { - PRINTF("in faultTolerantScheme *** Leon3FT detected, configure the CCR FT bits"); + PRINTF("in faultTolerantScheme *** Leon3FT detected, configure the CCR FT bits\n"); cacheControlRegister = CCR_getValue(); cacheControlRegister = (cacheControlRegister | 0xc); CCR_setValue(cacheControlRegister); @@ -163,7 +163,7 @@ static void CCR_getInstructionAndDataErr //******************************************* // ASR16 Register protection control register -static unsigned int ASR16_get_FPRF_IURF_ErrorCounters( unsigned int* fprfErrorCounter, unsigned int* iurfErrorCounter) +static void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int* fprfErrorCounter, unsigned int* iurfErrorCounter) { /** This function is used to retrieve the integer unit register file error counter and the floating point unit * register file error counter @@ -182,7 +182,7 @@ static unsigned int ASR16_get_FPRF_IURF_ *iurfErrorCounter = ( asr16 & COUNTER_FIELD_IURF ) >> POS_IURF; // reset the counter to 0 - asr16 = asr16Ptr + asr16 = asr16 & COUNTER_MASK_FPRF & COUNTER_FIELD_IURF; diff --git a/header/fsw_spacewire.h b/header/fsw_spacewire.h --- a/header/fsw_spacewire.h +++ b/header/fsw_spacewire.h @@ -28,7 +28,7 @@ int spacewire_open_link( void ); int spacewire_start_link( int fd ); int spacewire_stop_and_start_link( int fd ); int spacewire_configure_link(int fd ); -int spacewire_reset_link( void ); +int spacewire_several_connect_attemps( void ); void spacewire_set_NP( unsigned char val, unsigned int regAddr ); // No Port force void spacewire_set_RE( unsigned char val, unsigned int regAddr ); // RMAP Enable void spacewire_compute_stats_offsets( void ); diff --git a/python_scripts/LFRControlPlugin_reload_fsw.py b/python_scripts/LFRControlPlugin_reload_fsw.py --- a/python_scripts/LFRControlPlugin_reload_fsw.py +++ b/python_scripts/LFRControlPlugin_reload_fsw.py @@ -8,7 +8,7 @@ dsu3plugin0.loadFile() dsu3plugin0.run() # START SENDING TIMECODES AT 1 Hz -SpwPlugin0.StarDundeeStartTimecodes( 1 ) +#SpwPlugin0.StarDundeeStartTimecodes( 1 ) # it is possible to change the time code frequency #RMAPPlugin0.changeTimecodeFrequency(2) diff --git a/src/fsw_init.c b/src/fsw_init.c --- a/src/fsw_init.c +++ b/src/fsw_init.c @@ -95,7 +95,7 @@ void initCache() CCR_faultTolerantScheme(); - // FT activation + PRINTF("\n"); } rtems_task Init( rtems_task_argument ignored ) @@ -124,9 +124,8 @@ rtems_task Init( rtems_task_argument ign rtems_isr_entry old_isr_handler; // UART settings - send_console_outputs_on_apbuart_port(); + enable_apbuart_transmitter(); set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); - enable_apbuart_transmitter(); DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") diff --git a/src/fsw_misc.c b/src/fsw_misc.c --- a/src/fsw_misc.c +++ b/src/fsw_misc.c @@ -146,7 +146,7 @@ void watchdog_start(void) } -int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port +int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register { struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; @@ -155,15 +155,6 @@ int send_console_outputs_on_apbuart_port return 0; } -int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register -{ - struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; - - apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; - - return 0; -} - void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) { /** This function sets the scaler reload register of the apbuart module @@ -178,6 +169,7 @@ void set_apbuart_scaler_reload_register( struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; apbuart_regs->scaler = value; + BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) } diff --git a/src/fsw_spacewire.c b/src/fsw_spacewire.c --- a/src/fsw_spacewire.c +++ b/src/fsw_spacewire.c @@ -63,11 +63,11 @@ rtems_task spiq_task(rtems_task_argument } // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT - status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) + status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2) if ( linkStatus != 5 ) // [2.a] not in run state, reset the link { spacewire_compute_stats_offsets(); - status = spacewire_reset_link( ); + status = spacewire_several_connect_attemps( ); } else // [2.b] in run state, start the link { @@ -93,7 +93,8 @@ rtems_task spiq_task(rtems_task_argument else // [3.b] the link is not in run state, go in STANDBY mode { status = enter_mode_standby(); - if ( status != RTEMS_SUCCESSFUL ) { + if ( status != RTEMS_SUCCESSFUL ) + { PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status) } // wake the WTDG task up to wait for the link recovery @@ -477,7 +478,7 @@ int spacewire_configure_link( int fd ) return status; } -int spacewire_reset_link( void ) +int spacewire_several_connect_attemps( void ) { /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver. * diff --git a/src/tc_handler.c b/src/tc_handler.c --- a/src/tc_handler.c +++ b/src/tc_handler.c @@ -447,6 +447,7 @@ int check_mode_transition( unsigned char void update_last_valid_transition_date( unsigned int transitionCoarseTime ) { lastValidEnterModeTime = transitionCoarseTime; + PRINTF1("lastValidEnterModeTime = %x\n", transitionCoarseTime); } int check_transition_date( unsigned int transitionCoarseTime ) @@ -465,12 +466,12 @@ int check_transition_date( unsigned int { localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; - PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) + PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); - if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 + if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 { status = LFR_DEFAULT; - PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") + PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); } if (status == LFR_SUCCESSFUL) diff --git a/src/wf_handler.c b/src/wf_handler.c --- a/src/wf_handler.c +++ b/src/wf_handler.c @@ -869,41 +869,59 @@ void snapshot_resynchronization( unsigne unsigned long long int nextTick; unsigned long long int deltaPreviousTick; unsigned long long int deltaNextTick; - unsigned int deltaTickInF2; + int deltaTickInF2; double deltaPrevious_ms; double deltaNext_ms; + double correctionInF2; + static unsigned char resynchroEngaged = 0; - // get acquisition time in fine time ticks - acquisitionTime = get_acquisition_time( timePtr ); + if (resynchroEngaged == 0) + { + resynchroEngaged = 1; + // get acquisition time in fine time ticks + acquisitionTime = get_acquisition_time( timePtr ); - // compute center time - centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; - previousTick = centerTime - (centerTime & 0xffff); - nextTick = previousTick + 65536; + // compute center time + centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; + previousTick = centerTime - (centerTime & 0xffff); + nextTick = previousTick + 65536; - deltaPreviousTick = centerTime - previousTick; - deltaNextTick = nextTick - centerTime; + deltaPreviousTick = centerTime - previousTick; + deltaNextTick = nextTick - centerTime; + + deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.; + deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.; + + PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious_ms, deltaNext_ms); + PRINTF2("delta previous = %llu fine time ticks, delta next = %llu fine time ticks\n", deltaPreviousTick, deltaNextTick); - deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.; - deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.; - - PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious_ms, deltaNext_ms); - PRINTF2("delta previous = %llu fine time ticks, delta next = %llu fine time ticks\n", deltaPreviousTick, deltaNextTick); + // which tick is the closest? + if (deltaPreviousTick > deltaNextTick) + { + // the snapshot center is just before the second => increase delta_snapshot + correctionInF2 = + (deltaNext_ms * 256. / 1000. ); + } + else + { + // the snapshot center is just after the second => decrease delta_snapshot + correctionInF2 = - (deltaPrevious_ms * 256. / 1000. ); + } - // which tick is the closest - if (deltaPreviousTick > deltaNextTick) - { - // the snapshot center is just before the second => increase delta_snapshot - deltaTickInF2 = ceil( (deltaNext_ms * 256. / 1000.) ); - waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + 1 * deltaTickInF2; - PRINTF2("correction of = + %u, delta_snapshot = %d\n", deltaTickInF2, waveform_picker_regs->delta_snapshot); + if (correctionInF2 >=0 ) + { + deltaTickInF2 = floor( correctionInF2 ); + } + else + { + deltaTickInF2 = ceil( correctionInF2 ); + } + waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; + PRINTF2("Correction of = %d, delta_snapshot = %d\n\n", deltaTickInF2, waveform_picker_regs->delta_snapshot); } else { - // the snapshot center is just after the second => decrease delat_snapshot - deltaTickInF2 = ceil( (deltaPrevious_ms * 256. / 1000.) ); - waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - 1 * deltaTickInF2; - PRINTF2("correction of = - %u, delta_snapshot = %d\n", deltaTickInF2, waveform_picker_regs->delta_snapshot); + PRINTF1("No resynchro, delta_snapshot = %d\n\n", waveform_picker_regs->delta_snapshot); + resynchroEngaged = 0; } }