|
so here is the situation now.
[code] #include "AT91SAM7S64.h" /* AT91SAM7S64 definitions */ #define BR 115200 /* Baud Rate */ #define MCK 47923200
#define US_RXD_PIN AT91C_PA5_RXD0 /* JP9 must be close */ #define US_TXD_PIN AT91C_PA6_TXD0 /* JP7 must be close */ #define US_RTS_PIN AT91C_PA7_RTS0 /* JP8 must be close */ #define US_CTS_PIN AT91C_PA8_CTS0 /* JP6 must be close */
void main (void) //----------------------> change it to main so it executes with out getting called. { /* Initialize Serial Interface */ *AT91C_PIOA_PDR = AT91C_PA5_RXD0 | /* Enable RxD0 Pin */ AT91C_PA6_TXD0; /* Enalbe TxD0 Pin */
AT91C_BASE_US0->US_CR = AT91C_US_RSTRX | /* Reset Receiver */ AT91C_US_RSTTX | /* Reset Transmitter */ AT91C_US_RXDIS | /* Receiver Disable */ AT91C_US_TXDIS; /* Transmitter Disable */
AT91C_BASE_US0->US_MR = AT91C_US_USMODE_NORMAL | /* Normal Mode */ AT91C_US_CLKS_CLOCK | /* Clock = MCK */ AT91C_US_CHRL_8_BITS | /* 8-bit Data */ AT91C_US_PAR_NONE | /* No Parity */ AT91C_US_NBSTOP_1_BIT; /* 1 Stop Bit */
AT91C_BASE_US0->US_BRGR = (MCK/(16 * BR)); /* Baud Rate Divisor, from master clock */
AT91C_BASE_US0->US_CR = AT91C_US_RXEN | /* Receiver Enable */ AT91C_US_TXEN; /* Transmitter Enable */
sendchar("L"); //------------> I thought I should call it from the main function so it can sent "L" to seria
}
int sendchar (int ch) { /* Write character to Serial Port */ if (ch == '\n') { /* Check for CR */ while (!(AT91C_BASE_US0->US_CSR & AT91C_US_TXRDY)); /* Wait for Empty Tx Buffer */ AT91C_BASE_US0->US_THR = '\r'; /* Output CR */ } while (!(AT91C_BASE_US0->US_CSR & AT91C_US_TXRDY)); /* Wait for Empty Tx Buffer */ return (AT91C_BASE_US0->US_THR = ch); /* Transmit Character */ }
int getkey (void) { /* Read character from Serial Port */ while (!(AT91C_BASE_US0->US_CSR & AT91C_US_RXRDY)); /* Wait for Full Rx Buffer */ return (AT91C_BASE_US0->US_RHR); /* Read Character */ }
[/code]
complied it: [code] [me@localhost Blinking_LED]$ armv5tel-redhat-linux-gnueabi-gcc -o serial serial.c serial.c: In function ‘main’: serial.c:12: warning: return type of ‘main’ is not ‘int’ [me@localhost Blinking_LED]$
[/code]
Loaded it on the board: [code] J-Link>h //------------>stop processor PC: (R15) = 00000000, CPSR = 00000000 (Unknown mode, ARM) R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000 R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000 USR: R8 =00000000, R9 =00000000, R10=00000000, R11 =00000000, R12 =00000000 R13=00000000, R14=00000000 FIQ: R8 =00000000, R9 =00000000, R10=00000000, R11 =00000000, R12 =00000000 R13=00000000, R14=00000000, SPSR=00000000 SVC: R13=00000000, R14=00000000, SPSR=00000000 ABT: R13=00000000, R14=00000000, SPSR=00000000 IRQ: R13=00000000, R14=00000000, SPSR=00000000 UND: R13=00000000, R14=00000000, SPSR=00000000
J-Link>loadbin /home/me/Desktop/Blinking_LED/serial 0x003000 //----------->file loaded at this location Loading binary file... [/home/me/Desktop/Blinking_LED/serial] Writing bin data into target memory @ 0x00003000. J-Link>setpc 0x003000 //------------------> set memory to so cpu can start from here J-Link>go
J-Link>h PC: (R15) = 00000000, CPSR = 00000000 (Unknown mode, ARM) R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000 R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000 USR: R8 =00000000, R9 =00000000, R10=00000000, R11 =00000000, R12 =00000000 R13=00000000, R14=00000000 FIQ: R8 =00000000, R9 =00000000, R10=00000000, R11 =00000000, R12 =00000000 R13=00000000, R14=00000000, SPSR=00000000 SVC: R13=00000000, R14=00000000, SPSR=00000000 ABT: R13=00000000, R14=00000000, SPSR=00000000 IRQ: R13=00000000, R14=00000000, SPSR=00000000 UND: R13=00000000, R14=00000000, SPSR=00000000 J-Link>setpc 0x003000 J-Link>setpc 0x003000 J-Link>go J-Link>mem 0x00003000 Syntax: mem <Addr>, <NumBytes> J-Link>mem 0x00003000 90 Could not read memory. J-Link>mem 0x00003000 9 Could not read memory. J-Link>mem 0x00003000
[/code]
nothing on minicom,
minicom is set on same baudrate, no HW flow..
|