void checkDivide(float div){ setDivide(div); loop(); // int pulses = div*16+1; int pulses = divider.value+1; int i; for(i=0; !divideIsHigh() && i<100; ++i) pulseClock(); BOOST_CHECK_EQUAL(i, pulses); for(i=0; divideIsHigh() && i<100; ++i) pulseClock(); BOOST_CHECK_EQUAL(i, pulses); }
/* requirement is also satisfied. */ void waitTime(long microsec) { static long tckCyclesPerMicrosec = 1; /* must be at least 1 */ long tckCycles = microsec * tckCyclesPerMicrosec; long i; /* This implementation is highly recommended!!! */ /* This implementation requires you to tune the tckCyclesPerMicrosec variable (above) to match the performance of your embedded system in order to satisfy the microsec wait time requirement. */ for ( i = 0; i < tckCycles; ++i ) { pulseClock(); } #if 0 /* Alternate implementation */ /* For systems with TCK rates << 1 MHz; Consider this implementation. */ /* This implementation does not work with Spartan-3AN or indirect flash programming. */ if ( microsec >= 50L ) { /* Make sure TCK is low during wait for XC18V00/XCFxxS */ /* Or, a running TCK implementation as shown above is an OK alternate */ setPort( TCK, 0 ); /* Use Windows Sleep(). Round up to the nearest millisec */ _sleep( ( microsec + 999L ) / 1000L ); } else /* Satisfy FPGA JTAG configuration, startup TCK cycles */ { for ( i = 0; i < microsec; ++i ) { pulseClock(); } } #endif #if 0 /* Alternate implementation */ /* This implementation is valid for only XC9500/XL/XV, CoolRunner/II CPLDs, XC18V00 PROMs, or Platform Flash XCFxxS/XCFxxP PROMs. This implementation does not work with FPGAs JTAG configuration. */ /* Make sure TCK is low during wait for XC18V00/XCFxxS PROMs */ /* Or, a running TCK implementation as shown above is an OK alternate */ setPort( TCK, 0 ); /* Use Windows Sleep(). Round up to the nearest millisec */ _sleep( ( microsec + 999L ) / 1000L ); #endif }
void shiftOut(unsigned char val) { char i; // Iterate over each bit, set data pin, and pulse the clock to send it // to the shift register for (i = 0; i < 8; i++) { pinWrite(DATA, (val & (1 << i))); pulseClock(); } }
void shiftOut(char output, char pin){ outputDisable(pin); for(int i = 0; i <= 7; i++){ int set = (output >> i) & 0x01; if(set == 1){ data1(); } else { data0(); } pulseClock(); } pulseClock(); outputEnable(pin); __delay_us(100); outputDisable(pin); return; }
// Take the given 8-bit value and shift it out, LSB to MSB void shiftOut(unsigned char val) { //Set latch to low (should be already) P2OUT &= ~LATCH; char i; // Iterate over each bit, set data pin, and pulse the clock to send it // to the shift register for (i = 0; i < 8; i++) { pinWrite(DATA, (val & (1 << i))); pulseClock(); } // Pulse the latch pin to write the values into the storage register P2OUT |= LATCH; P2OUT &= ~LATCH; }