Цитата(Sergey'F @ Sep 17 2009, 13:11)

Честно говоря, весь код раскапывать тяжко.
Для начала вопрос - сигнал на ножке TX есть? В контроллере PIOA настроены ножки USART соответствующим образом?
Стоило только отправить вопрос на форум... и озарение пришло само сабой :-)... Я не совсем корректно модифицировал исходный пример, и соответственно происходила неправильная конфигурация PIO, вернее мной эта часть кода в виду невнимательности была вообще отброшена, соответственно и неудачный результат.
Все же для тех, кому интересен чужой хождения по грабелькам, выложу то, что у меня в итоге получилось :-)
CODE
/*Headers */
#include <board.h>
#include <pio/pio.h>
#include <pio/pio_it.h>
#include <aic/aic.h>
#include <usart/usart.h>
#include <tc/tc.h>
#include <led.h>
#include <stdio.h>
//#include "JLINKDCC.h"
/* Defines*/
/// Delay for pushbutton debouncing (in milliseconds).
#define DEBOUNCE_TIME 500
/// PIT period value in µseconds.
#define PIT_PERIOD 1000
/*Global variables*/
const Pin pinPB1 = PIN_PUSHBUTTON_1;
const Pin pinPB2 = PIN_PUSHBUTTON_2;
const Pin pinPB3 = PIN_PUSHBUTTON_3;
const Pin pinPB4 = PIN_PUSHBUTTON_4;
static int result;
/// Maximum Bytes Per Second (BPS) rate that will be forced using the CTS pin.
#define MAX_BPS 500
/// Size of the receive buffer used by the PDC, in bytes.
#define BUFFER_SIZE 3
/// Pins to configure for the application.
const Pin UARTpins[] = {
PINS_DBGU,
PIN_USART0_RXD,
PIN_USART0_TXD,
PIN_USART0_CTS,
PIN_USART0_RTS
};
/// Number of bytes received between two timer ticks.
volatile unsigned int bytesReceived = 0;
/// Receive buffer.
unsigned char pBuffer[BUFFER_SIZE];
/// String buffer.
char pString[24];
/* Interrupt handlers*/
//------------------------------------------------------------------------------
/// Interrupt handler for TC0. Displays the number of bytes received during the
/// last second and the total number of bytes received, then restarts a read
/// transfer on the USART if it was stopped.
//------------------------------------------------------------------------------
void ISR_Tc0(void)
{
unsigned int status;
static unsigned int bytesTotal = 0;
// Read TC0 status
status = AT91C_BASE_TC0->TC_SR;
// RC compare
if ((status & AT91C_TC_CPCS) == AT91C_TC_CPCS)
{// проверка работы прерывания таймера счетчика 0
LED_Toggle(3);// зажигаем светодиод
sprintf(pString, "hallo, world /n");
USART_WriteBuffer(AT91C_BASE_US0, pString, sizeof(pString));
}
}
//------------------------------------------------------------------------------
/// Interrupt handler for USART0. Increments the number of bytes received in the
/// current second and starts another transfer if the desired bps has not been
/// met yet.
//------------------------------------------------------------------------------
void ISR_Usart0(void)
{// прерывание от USART0
unsigned int status;
// Read USART status
status = AT91C_BASE_US0->US_CSR;
// Receive buffer is full
if ((status & AT91C_US_RXBUFF) == AT91C_US_RXBUFF)
{
LED_Toggle(0);
USART_ReadBuffer(AT91C_BASE_US0, pBuffer, BUFFER_SIZE);
USART_WriteBuffer(AT91C_BASE_US0, pBuffer, BUFFER_SIZE);
}
}
///*Functions*/
//void ConfigurePit(void)
//{
// // Initialize the PIT to the desired frequency
// PIT_Init(PIT_PERIOD, BOARD_MCK / 1000000);
//
// // Configure interrupt on PIT
// AIC_DisableIT(AT91C_ID_SYS);
// AIC_ConfigureIT(AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST, ISR_Pit);
// AIC_EnableIT(AT91C_ID_SYS);
// PIT_EnableIT();
//
// // Enable the pit
// PIT_Enable();
//}
void ConfigureButtons(void)
{// конфигурация кнопочек
#if defined(at91sam7lek)
const Pin pinCol0 = PIN_KEYBOARD_COL0;
PIO_Configure(&pinCol0, 1);
#endif
#if defined(at91cap9dk)
const Pin pinRow0 = PIN_KEYBOARD_ROW0;
PIO_Configure(&pinRow0, 1);
#endif
// Configure pios
PIO_Configure(&pinPB1, 1);
PIO_Configure(&pinPB2, 1);
PIO_Configure(&pinPB3, 1);
PIO_Configure(&pinPB4, 1);
// Initialize interrupts
// PIO_InitializeInterrupts(AT91C_AIC_PRIOR_LOWEST);
// PIO_ConfigureIt(&pinPB1, (void (*)(const Pin *)) ISR_Bp1);
// PIO_ConfigureIt(&pinPB2, (void (*)(const Pin *)) ISR_Bp2);
// PIO_ConfigureIt(&pinPB3, (void (*)(const Pin *)) ISR_Bp3);
// PIO_ConfigureIt(&pinPB4, (void (*)(const Pin *)) ISR_Bp4);
//
// PIO_EnableIt(&pinPB1);
// PIO_EnableIt(&pinPB2);
// PIO_EnableIt(&pinPB3);
// PIO_EnableIt(&pinPB4);
}
void ConfigureLeds(void)
{//
LED_Configure(0);
LED_Configure(1);
LED_Configure(2);
LED_Configure(3);
}
//------------------------------------------------------------------------------
/// Configures Timer Counter 0 (TC0) to generate an interrupt every second. This
/// interrupt will be used to display the number of bytes received on the USART.
//------------------------------------------------------------------------------
void ConfigureTc0(void)
{
unsigned int div, tcclks;
// Enable TC0 peripheral clock
PMC_EnablePeripheral(AT91C_ID_TC0);
/// Configure TC for a 1s (= 1Hz) tick
TC_FindMckDivisor(1, BOARD_MCK, &div, &tcclks);
TC_Configure(AT91C_BASE_TC0, tcclks | AT91C_TC_CPCTRG);
AT91C_BASE_TC0->TC_RC = (BOARD_MCK / (2 * div));
// Configure interrupt on RC compare
AIC_ConfigureIT(AT91C_ID_TC0, 0, ISR_Tc0);
AT91C_BASE_TC0->TC_IER = AT91C_TC_CPCS;
AIC_EnableIT(AT91C_ID_TC0);
}
//------------------------------------------------------------------------------
/// Configures USART0 in hardware handshaking mode, asynchronous, 8 bits, 1 stop
/// bit, no parity, 115200 bauds and enables its transmitter and receiver.
//------------------------------------------------------------------------------
void ConfigureUsart0(void)
{//
unsigned int mode = AT91C_US_USMODE_NORMAL
| AT91C_US_CLKS_CLOCK
| AT91C_US_CHRL_8_BITS
| AT91C_US_PAR_NONE
| AT91C_US_NBSTOP_1_BIT
| AT91C_US_CHMODE_NORMAL;
// Enable the peripheral clock in the PMC
PMC_EnablePeripheral(AT91C_ID_US0);
// Configure the USART in the desired mode @115200 bauds
USART_Configure(AT91C_BASE_US0, mode, 115200, BOARD_MCK);
// Configure the RXBUFF interrupt
AIC_ConfigureIT(AT91C_ID_US0, 0, ISR_Usart0);
AIC_EnableIT(AT91C_ID_US0);
// Enable receiver & transmitter
USART_SetTransmitterEnabled(AT91C_BASE_US0, 1);
USART_SetReceiverEnabled(AT91C_BASE_US0, 1);
}
/* Main */
int main()
{
PIO_Configure(UARTpins, PIO_LISTSIZE(UARTpins));
ConfigureLeds();
ConfigureButtons();
ConfigureUsart0();
// ConfigureTc0();// Configure TC0 to generate a 1s tick
// Start receiving data and start timer
USART_ReadBuffer(AT91C_BASE_US0, pBuffer, BUFFER_SIZE);
AT91C_BASE_US0->US_IER = AT91C_US_RXBUFF;//
// TC_Start(AT91C_BASE_TC0);//
while (1);
return 0;
}
Причина редактирования: Уменьшение видимого размера цитаты исходника.