avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] RE: avr-gcc-list Digest, Vol 23, Issue 14


From: wbounce
Subject: [avr-gcc-list] RE: avr-gcc-list Digest, Vol 23, Issue 14
Date: Sun, 12 Dec 2004 23:12:34 -0500

>From the data sheet 
. SS - Port B, Bit 0
SS: Slave Port Select input. When the SPI is enabled as a slave, this
pin is configured
as an input regardless of the setting of DDB0. As a slave, the SPI is
activated when this
pin is driven low. When the SPI is enabled as a master, the data
direction of this pin is
controlled by DDB0. When the pin is forced to be an input, the pull-up
can still be controlled
by the PORTB0 bit.
Table 31 and Table 32 relate the alternate functions
End data sheet

Not to agrue that point, but that pin is the only pin that seems
remotely related to programming. Anyhow, I can not send anything to the
board or read anything from the board right now. 

After looking the 2 documents I used to build my programmer cable, I
have to say you are correct they do not mention SS they only mention
RESET,SCK, MOSI, MISO, and ground. And the header is called a ISP header
not a SPI header.

So I am still stuck trying to figure out why I can not program. 

After looking at the data sheet some more I see where they reference 2
different SPI interfaces. 
One being the O/I module ie transfer data between 2 AVRs. The other
being the SPI programming module which you referenced as ISP.

>From the data sheet:
Even though the SPI Programming interface re-uses the SPI I/O module,
there is one
important difference: The MOSI/MISO pins that are mapped to PB2 and PB3
in the SPI
I/O module are not used in the Programming interface. Instead, PE0 and
PE1 are used
for data in SPI Programming mode as shown in Table 128.

Table 128. Pin Mapping SPI Serial Programming
Symbol Pins I/O Description
MOSI (PDI) PE0 I Serial data in
MISO (PDO) PE1 O Serial data out
SCK PB1 I Serial clock
End of data sheet

Port E pin 0 and 1 are also used for uart 0. So maybe we are getting
somewhere since I am writing to the uart. 

Also your statement  about the /PEN pin is interesting

>From the datasheet
To program and verify the ATmega128 in the SPI Serial Programming mode,
the following
sequence is recommended (See four byte instruction formats in Table
145):
1. Power-up sequence:
Apply power between VCC and GND while RESET and SCK are set to "0". In
some systems, the programmer can not guarantee that SCK is held low
during
power-up. In this case, RESET must be given a positive pulse of at least
two
CPU clock cycles duration after SCK has been set to "0".
As an alternative to using the RESET signal, PEN can be held low during
Poweron
Reset while SCK is set to "0". In this case, only the PEN value at
Power-on
Reset is important. If the programmer cannot guarantee that SCK is held
low
during power-up, the PEN method cannot be used. The device must be
powered
down in order to commence normal operation when using this method.
2. Wait for at least 20 ms and enable SPI Serial Programming by sending
the Programming
Enable serial instruction to pin MOSI.
End of data sheet

Note the data sheet says holding the PEN is an alternative method. I
suspect the reset method is being used by avrdude because my currently
loaded program interupts for a short period of time when I run the
AVRDude.  As far as I can tell from the board schematic the PEN pin is
not tied to anything so I do not know how I would be able to bring it
low. I will send a question to the board designer about that. 

-----Original Message-----

Date: Sun, 12 Dec 2004 10:57:09 -0800
From: "Larry Barello" <address@hidden>
Subject: RE: [avr-gcc-list] RE: Question about programming a ATMEGA128

SS is not used for SPI programming.  Reset, MISO, MOSI and SCK are used.

If /PEN is low and reset is asserted, then the chip is in ISP (spi)
programming mode.

The usual mistake on the 128 is to assume the SPI port is the ISP port.
They are not the same thing (although they ARE the same on almost every
other chip).

-----Original Message-----
Sent: Sunday, December 12, 2004 10:27 AM
To: address@hidden
Subject: [avr-gcc-list] RE: Question about programming a ATMEGA128

After reading the datasheet last night, I realize the Port B pin 0 that
I am using for the onboard led has a dual function of SS which is used
during SPI programming.

The program loaded in the chip does  DDRB = 0x01; as the 1st line of
main.

Then it inits the timers, pwm, and uart; prints a welcome message;
delays for 500 ms; then starts a loop that toggles portb pin 0 among
other things.

I am guessing the DDRB statement setting the pins as output and the pull
up registers are pulling it high and this is causing my programming
problem.

How can I reprogram my board? I looked at the AVRdude documentation and
did not see anything obvious to help. I am open to all ideas..

Sorry if you replied to my original post. My list option is digest and I
won't see your responses until tonight. And I can not see the list
online right now because my internet browsing is down even though I have
email.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]