BIT_COUNT: MOVEM.L A0-A1/D2-D3,-(SP) // save CPU regs
MOVE.L D0,-(SP) // save D0 to known place on stack
MOVE.L D1,-(SP) // likewise, save D1 to stack
MOVE.L 32(SP),A0 // get first longword address
MOVE.L 28(SP),A1 // get last longword address
ADDA.L #3,A1 // create last byte address
CLR.L D0 // clear count (1) of 0's
CLR.L D1 // clear count (2) of 1's
LOOP1: MOVE.B (A0)+,D2 // get next even-addressed byte
CLR.L D3 // initialize bit counter for byte
LOOP2: BTST.B D3,D2 // is the next bit a 0?
BNE SKIP1 // skip increment if 1
ADDQ.L #1,D0 // increment count of 0's
SKIP1: ADDQ.L #1,D3 // increment bit ptr
CMPI.L #8,D3 // finished present byte?
BLT LOOP2 // if not, go back to next bit
MOVE.B (A0)+,D2 // get next odd-addressed byte
CLR.L D3 // initialize bit counter for byte
LOOP3: BTST.B D3,D2 // is the next bit a 1?
BEQ SKIP2 // skip increment if 0
ADDQ.L #1,D1 // increment count of 1's
SKIP2: ADDQ.L #1,D3 // increment bit ptr
CMPI.L #8,D3 // finished present byte?
BLT LOOP3 // if not, go back to next bit
CMPA A1,A0 // check if done last byte
BLT LOOP1 // loop back if A0 < A1
MOVE.W D1,2(SP) // write count (1) to saved D1.W
MOVE.W D0,6(SP) // write count (2) to saved D0.W
MOVE.L (SP)+,D1 // restore D1 with count (1)
MOVE.L (SP)+,D0 // restore D0 with count (2)
MOVEM.L (SP)+,A0-A1/D2-D3 // restore CPU regs
RTS
extern "C" {
void UserMain( void *Pd );
}
DWORD TaskTStack[ USER_TASK_STK_SIZE ] __attribute__( ( aligned(4) ) );
DWORD TaskAStack[ USER_TASK_STK_SIZE ] __attribute__( ( aligned(4) ) );
DWORD TaskBStack[ USER_TASK_STK_SIZE ] __attribute__( ( aligned(4) ) );
OS_SEM SemaphoreA, SemaphoreB;
void TaskA( void *pd )
{
current_state = reset_state_for_A;
while (1) {
OSSemPend( &SemaphoreA );
// Execute code in current_state
// update next_state according to inputs and the current state
current_state = next_state;
} // end while (1)
}
void TaskB( void *pd )
{
current_state = reset_state_for_B;
while (1) {
OSSemPend( &SemaphoreB );
// Execute code in current_state
// update next_state according to inputs and the current state
current_state = next_state;
} // end while (1)
}
void TaskT( void *pd )
{
while (1) {
OSTimeDly( TICS_PER_SECOND * 0.040 );
OSSemPost( &SemaphoreA );
OSSemPost( &SemaphoreB );
OSTimeDly( TICS_PER_SECOND * 0.040 );
OSSemPost( &SemaphoreB );
} // end while (1)
}
// Task UserMain
void UserMain( void *pd ) {
OSChangePrio( MAIN_PRIO );
OSSemInit( &SemaphoreA, 0 );
OSSemInit( &SemaphoreB, 0 );
OSTaskCreate( TaskT, (void *) 0,
&TaskTStack[USER_TASK_STK_SIZE],
TaskTStack, MAIN_PRIO-3 );
OSTaskCreate( TaskA, (void *) 0,
&TaskAStack[USER_TASK_STK_SIZE],
TaskAStack, MAIN_PRIO-2 );
OSTaskCreate( TaskB, (void *) 0,
&TaskBStack[USER_TASK_STK_SIZE],
TaskBStack, MAIN_PRIO-1 );
while (1) {
OSTimeDly( TICKS_PER_SECOND * 5 );
} // end while
}
The noise margin provides a degree of immunity against noise that might get introduced onto a digital signal. The source of the noise could be electromagnetically coupled noise, ground voltage noise, offsets in the power supply voltage of the transmitting and receiving sides, etc.
Bit #7 in the UISR is the "Change Of State" (COS) bit. It is used to detect the next 0-to-1 or 1-to-0 transition in the UnCTS (Clear To Send) line provided this feature has been enabled in the UACRn register.
Bit #2 in the UISR is the "Delta break" bit. It is used to detect a a break signal (i.e. a low voltage "space" signal that lasts longer than the time for one character frame).
Bit #1 in the UISR is the "FIFO Full/Receiver Ready" (FFULL/RxRDY) bit. The operation of this bit depends on the bit value that is stored in the FFULL/RxRDY bit in register UMR1. If this other bit is 1, then bit #1 in the UISR has value 1 if the receiver First In First Out (FIFO) buffer is full; otherwise, bit #1 has value 0. If the FFULL/RxRDY bit in register UMR1 is 0, then bit #1 in the UISR is a Receiver Ready (RxRDY) bit that has value 1 if the receiver is "ready" (has a new character for the CPU to read) and has value 0 if the receiver has no new characters to read.
Bit #0 in the UISR is the Transmitter Ready (TxRDY) bit. It has value 1 if the transmitter can accept another character to transmit and the transmitter is currently enabled to transmit; otherwise, bit #0 has value 0.
Bit #23 of the Ethernet Interrupt Event Register (EIR) will be set after a 32-bit shifting sequence from the MMFR has been completed. This is a useful feature since the MDC clock runs more slowly than the CPU clock. The CPU can do other useful work wile the MII frame is being shifted, and only when that operation is completed will the CPU be alerted by means of the MII interrupt. For the MII interrupt to be enabled through to the CPU as a hardware signal, the MII bit in the Ethernet Interrupt Mask Register (EIMR) must hold a 1.
The transmit BDs are used by the transmitter to locate the various buffers that contain the bits in a transmitted frame. It is convenient to split up such a frame into pieces so that software can more easily access different kinds of information. For example, separate transmit buffers might be used to store the Ethernet header, the IP header, the TCP header, the application payload, and the Ethernet trailer.