Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: A million dollar question
PostPosted: Fri Mar 25, 2011 9:20 pm 
Offline

Joined: Fri Mar 11, 2011 11:10 pm
Posts: 7
So you have downloaded your code on the board, and its not working how the censored you look at any out put at all.

Before any one assume any thing let me tell you some thing I read two books

1-embedded system on shoe string
2- programming embedded c with gnu

Now both those smart author said some thing like this


host(linux) target(at91sam7 hb)
|-----------|
|_______|-------------------jtag------------|_____|-
| |
|________________serial---------------|

Which is pretty reasonable, you get output from target on serial. Target usually has some kind of supportive os(redboot or some thing)

Now I got this board I can down load code on, at any location, I can verify it looking at bin out put from that location and binary out put from host. It matches.

Now when I do setPC on that location and do go.
there is pitch black.

Tools I am using.

1-jlink(for linux) it does every thing fine, upload, bring back what it id told to.
2-my tool chain is fine too.

only thing is is there support from those boards to minicom/hyperteminal ??
Or its an old thing ???

Thanks.


Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Fri Mar 25, 2011 11:01 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Not that I follow all your English, but this would be the point where you throw in some breakpoints and do some bi-sectioning of the code to narrow down where things are going wrong, and do some single-step/tracing to pin-point the problem.

Get the serial output working VERY early in the code you are running, and output sporadic signs-of-life information, and bread-crumbs to figure out what's happening, and where it is has been.


Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Fri Mar 25, 2011 11:21 pm 
Offline

Joined: Fri Mar 11, 2011 11:10 pm
Posts: 7
oh...

so my code need to arrange serial communication ?

interesting....


Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Sat Mar 26, 2011 2:32 am 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
>>so my code need to arrange serial communication ?

Absent some other code to do it for you, you are going to have to initialize enough clocks and peripherals and pins to get it to work yourself.

Try looking at some sample code for your specific cpu or board.

#include <AT91SAM7S64.H> /* AT91SAM7S64 definitions */

#define BR 115200 /* Baud Rate */

void init_serial (void)
{ /* 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 */
}

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 */
}


Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Wed Mar 30, 2011 8:15 pm 
Offline

Joined: Fri Mar 11, 2011 11:10 pm
Posts: 7
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..


Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Wed Mar 30, 2011 10:39 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Then you will need to single-step into the code, using the "s" command, lighting it off into the darkness with "go" isn't going to tell you much.

You need to be more specific about the board you are using, the chip on it, how you have it wired up to a serial port, what startup code you are using (board_cstartup.s, crt0_gnu.s, or whatever), linker scripts, etc.

Where are you initializing the PLL?

Unless you are remapping it, the internal SRAM is located at 0x200000 (on a 7S64), I suggest you put your code there.

Personally I'm using the arm-none-eabi tools to build for AT91SAM9260 and 9G20 targets. If you want a half-decent debugging experience, do yourself a favour and download the demo/eval version of Keil uv3 or uv4, the 32K limit shouldn't impede you at this point.


Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Fri Apr 01, 2011 8:22 pm 
Offline

Joined: Fri Mar 11, 2011 11:10 pm
Posts: 7
This is the schematic of the board.

I did not initiate PPL, did not create linker either.

Thanks for your help.


Attachments:
Schem_AT91SAM7S_HB.jpg
Schem_AT91SAM7S_HB.jpg [ 113.74 KiB | Viewed 659 times ]
Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Fri Apr 01, 2011 9:10 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
So basically no serial port attached, and probably not clocking at 47.9232 MHz


Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Fri Apr 01, 2011 11:20 pm 
Offline

Joined: Fri Mar 11, 2011 11:10 pm
Posts: 7
hmm


There are infact 2 serial ports.

Infact it was confusing how PA5 can be open on the bread board and also used to do serial communication.

Then I assumed PA5 might not use absolute address, instead it gets tosed around depending on the mod we switch to.


Attachments:
IMG00085-20110401-1713.jpg
IMG00085-20110401-1713.jpg [ 67.25 KiB | Viewed 630 times ]
Top
 Profile  
 
 Post subject: Re: A million dollar question
PostPosted: Sat Apr 02, 2011 12:35 am 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Ok, then that would be the wrong schematic, as you have the AT91SAM7S-DB not the -HB

http://www.bravekit.com/document/ATMEL_ ... _schem.pdf

For the Debug UART to connect to the serial port, you will need to move jumpers JP5 & 6 to the 2-3 position. In the 1-2 position they go to the RS485 header.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: