|
Hello,
Ich have bought the book "C Programming for embedded microcontrollers" from "Warwick A. Smith". All examples are working without any problems, but the tx-serial example on page 203 didn`t make the right output. The output have to be: "Hello from DBGU port!" But on my PC I only get the half text like : "...om DBGU port". I use absolutely the same board (AT91SAM7S256-EK) like in the description from Warwick A. Smith. The crystal oszillator is correct and I have tested it with many kinds of serial cables. Now I use a crossover "Nullmodem" cable, like the description in the book. But when I would use a wrong cable, then I wouldn`t have any kind of output, is this correct? Can someone tell what`s the problem? Do I something wrong or is it a hardware problem? I have changed the settings of the HyperTerminal to 115200, 8, none,1, none. I have tested an other PC, but there I get only a symbol in the Hyperterminal like "..).." , nothing else, with the same settings. With an AT91SAM9260-EK and Eddy v2.5 DK the serial output works without any problems, thats the reason why I think to have a hardware problem with the AT91SAM7S256-EK. Here is the code.
#include "at91sam7s.h"
#define DBGU_115200 26
void DBGUInit(unsigned int baud); void DBGUTxMsg(char* msg);
int main(void) { DBGUInit(DBGU_115200); DBGUTxMsg("Hello from DBGU port\r\n"); //Here I only get "...om DBGU port" while (1) { } }
void DBGUInit(unsigned int baud) { /* connect the DBGU UART to PA9 & 10 */ PIO_ASR = 0x00000600; /* select the DBGU */ PIO_PDR = 0x00000600; /* DBGU controls the pins */ /* setup the DBGU UART */ DBGU_BRGR = baud; /* set baud rate */ DBGU_MR = 0x00000800; /* no parity, normal mode */ DBGU_CR = 0x00000050; /* enable tx and rx */ }
void DBGUTxMsg(char* msg) { int ch_num = 0; /* send characters until null received */ while (msg[ch_num] != 0) { while (!(DBGU_SR & 0x00000002)); DBGU_THR = (unsigned int)msg[ch_num]; ch_num++; } }
|