Silicon Laboratories Stepper Machine Manual do Utilizador Página 34

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 36
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 33
AN155
34 Rev. 1.1
}
//-----------------------------------------------------------------------------
void uartISR(void) interrupt 4 // main UART interrupt service routine
{
char dummy;
signed char i;
// Who done it?
if(RI0 == 1) // Was it the receiver?
{
RI0 = 0; // yep, clear receiver flag
// if not full
if (readCount != READ_BUFFER_SIZE)
{
readBuffer[readIndex]= SBUF0; // read char from UART
readIndex++; // increment index
if (readIndex == READ_BUFFER_SIZE)
readIndex = 0; // fix if out of range
readCount++; // one more in the buffer
}
else
{
dummy = SBUF0; // drop characters dummy!
}
}
if(TI0 == 1) // Was it the transmitter?
{
TI0 = 0; // yep, clear transmitter flag
if (writeCount>0) // if not empty
{
i = writeIndex - writeCount; // calculate where to get it
if (i < 0) // fix if out of range
i+=WRITE_BUFFER_SIZE;
SBUF0 = writeBuffer[i]; // write character to UART
writeCount--; // one less in the buffer
}
else
{
TX_Idle = 1; // set idle flag when empty
}
}
}
//-----------------------------------------------------------------------------
Vista de página 33
1 2 ... 29 30 31 32 33 34 35 36

Comentários a estes Manuais

Sem comentários