PSoC Cypress пишу обмен по UART, и нужно менять конфигурацию, так после остановки UART, он уже коректно не включается, пишу на си, пример привожу.
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено cheburator 23 февраля 2004 г. 07:54

некорректность заключается в том, что, что после остановки и включения, начинает гнать левые символы


#include // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules

#define REPL_BUF_LEN 6
BYTE repl_buffer[REPL_BUF_LEN];
BYTE bRxData;

BOOL fWaitToReceiveByte(void);
void TxZeroTerminatedRamString( BYTE * pbStrPtr );

void main()
{

TX8_1_Start(TX8_1_PARITY_NONE);
RX8_1_Start(RX8_1_PARITY_NONE);

str:


if ( fWaitToReceiveByte() )
{


repl_buffer[0] = bRxData;

TxZeroTerminatedRamString(repl_buffer);
}

TX8_1_Stop();
RX8_1_Stop();

goto str;

}

BOOL fWaitToReceiveByte(void)
{
BYTE bRxStatus;

/* Wait to receive full byte*/
while ( !( bRxStatus=RX8_1_bReadRxStatus() & RX8_1_RX_COMPLETE ) )
{
/* might want to sleep or keep track of time */
}
/* data received, now check for errors */
if (( bRxStatus & RX8_1_RX_NO_ERROR ) == 0 )
{
/* no error detected */
bRxData = RX8_1_bReadRxData();
return( TRUE );
}
else
{
/* error detected */
bRxData = bRxStatus;
return( FALSE );
}

}

//
// TX8_1_Start() should be called prior to calling this function.
//

void TxZeroTerminatedRamString( BYTE * pbStrPtr )
{


/* check for the end condition, before sending the next byte */
while( *pbStrPtr != 0 )
{
/* send the next byte */
TX8_1_SendData( *pbStrPtr );
/* Wait for the data to start transmitting */
while( !( TX8_1_bReadTxStatus() & TX8_1_TX_BUFFER_EMPTY ) );
pbStrPtr++;
}

}


Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru