Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
nikhil.garade
PostPosted: Oct 16, 2011 - 06:52 PM
Newbie


Joined: Oct 01, 2011
Posts: 5


I am using stk6oo with atmega2560( using usart0) to communicate with my PC.I use AVR studio 17 for coding and burning the code.I too do not see anything on my Bray's Terminal.

At pin PE1 which is the TXD as per the datasheet I see 5.1 V. I connect the RS232 spare header and Pins PE0 an PE1 as

follows:

Pin PE0 of usart0 to RXD of RS232 spare header and
Pin PE1 of usart0 to TXD of RS232 spare header
Is this connection correct and sufficient or is there anything else to be done other that the above connections and of course the power connection through USB and RS232 male connecter to the RS232 D sub(female coupler) of the stk600 board?

Could anyone please clarify what external connections are to be used?

Please excuse me for the length of my message. I thought I better be clear .

I have always used the traditional way of using 8 bits, 1 stop bit, no parity bits.

Also I have attached my 'fuses' tab screen shot along with .
Also is there any way to check what the actual frequency on board stk00 is?

Controller signature is consistent.
My fuses' status is as follows

Jtagen ,SPIEN checked and

Boot Flash size=4096 words start address=$1F000

SUT_CKSEL :Full Swing Oscillator; Start-up time: 16K CK + 65 ms; Crystal Osc.; slowly rising power

Brown out detection disabled and my clock generator is 8003456 when I read.
No other fuses are programmed.

My build details :

Also request to burn and run on your stk600 in Atmega2560 to find out to deduce where/what is problem .
If it runs fine on yor side then there's prob in my stk600.


Code:
Build started 16.10.2011 at 22:24:54
avr-gcc  -mmcu=atmega2560 -Wall -gdwarf-2 -std=gnu99                                      -DF_CPU=8000000UL -O0

-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT Braking.o -MF dep/Braking.o.d  -c  ../Braking.c
In file included from ../Braking.c:2:
c:/winavr-20090313/lib/gcc/../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions

from <util/delay.h> won't work as designed"
../Braking.c:5:1: warning: "F_CPU" redefined
<command-line>: warning: this is the location of the previous definition
avr-gcc -mmcu=atmega2560 -Wl,-Map=Braking.map Braking.o     -o Braking.elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature  Braking.elf Braking.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex

Braking.elf Braking.eep || exit 0
avr-objdump -h -S Braking.elf > Braking.lss

AVR Memory Usage
----------------
Device: atmega2560

Program:     384 bytes (0.1% Full)
(.text + .data + .bootloader)

Data:          0 bytes (0.0% Full)
(.data + .bss + .noinit)


Build succeeded with 3 Warnings...



My code goes as below taken from tutorial on this site
Code:

#include <avr/io.h>
#include <util/delay.h>


#define F_CPU 8003456
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)


int main (void)
{
   char ReceivedByte;


   UCSR0B |= (1 << RXEN0) | (1 << TXEN0);   // Turn on the transmission and reception circuitry
   UCSR0C |= (1 << UCSZ00) | (1 << UCSZ01); // Use 8-bit character sizes

   UBRR0H = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register
   UBRR0L = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register

   for (;;) // Loop forever
   {
      while ((UCSR0A & (1 << RXC0)) == 0) {}; // Do nothing until data have been received and is ready to be read from UDR
      ReceivedByte = UDR0; // Fetch the received byte value into the variable "ByteReceived"

      while ((UCSR0A & (1 << UDRE0)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
      UDR0 = ReceivedByte; // Echo back the received byte back to the computer
   }   
}


Any help will be greatly appreciated

Thanks and regards ,
NIkhil
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Oct 16, 2011 - 07:18 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62291
Location: (using avr-gcc in) Finchingfield, Essex, England

Code:
c:/winavr-20090313/lib/gcc/../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions

from <util/delay.h> won't work as designed"

Why have you ignored this?

Only one of these can be true:
Code:
avr-gcc  -mmcu=atmega2560 -Wall -gdwarf-2 -std=gnu99                                      -DF_CPU=8000000UL -O0
Code:
#define F_CPU 8003456

(my money on the first one)

You appear to have fused for crystal and those lines suggest it may be 8MHz - is that correct - how are you connecting this 8MHz crystal to the 2560?

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
nikhil.garade
PostPosted: Oct 17, 2011 - 04:24 AM
Newbie


Joined: Oct 01, 2011
Posts: 5


@ Clawson,
Thanks for your quick reply.

I have set my clock source to EXT mode on stk600 and fused it to
SUT_CKSEL :Full Swing Oscillator; Start-up time: 16K CK + 65 ms; Crystal Osc.; slowly rising power
No CKdiv8 programmed.
Hope that's right.
Before trying serial communication I flashed an LED for 1 sec delay using _delay_ms(1000).

My problems started after that.
Will remove the redefinition ,check it and fall back.
Am I right in understanding that I do not have to make any more connections other than using two pin wire for RS232 spare header i.e.,
Pin PE0 of usart0 to RXD of RS232 spare header and
Pin PE1 of usart0 to TXD of RS232 spare header.

Regards,
 
 View user's profile Send private message  
Reply with quote Back to top
nikhil.garade
PostPosted: Oct 17, 2011 - 07:02 AM
Newbie


Joined: Oct 01, 2011
Posts: 5


My observations are,
When I Just configure my UART registers and do nothing ,I see 5.1 V on my PE1.

when I try to only send a character 'a' I see 2.08 V on my PE1 and TXD pin on spare header and 5.22 V on PE0 and RXD on spare header.
I do not see anything on my terminal.


Earlier this day ,I also transmitted and received only on the serial cable by shorting RXD and TXD on cable. I saw on the terminal what I typed on my on the keyboard.
When I tried doing so by shorting RXD and TXD on spare header, I could not see anything on my terminal when I typed characters on my keyboard.
I am beginning to think that there's prob in my Stk now. Any suggestions?

Have already attached my fuse status jpeg above.
Am sending the code again..Is there anything else that I may be missing?
DO I still need to enable optimisation?
Have commented out the portion for receiving characters

Code:
#include <avr/io.h>
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)


int main (void)
{
// char ReceivedByte;




UCSR0B |= (1 << RXEN0) | (1 << TXEN0); // Turn on the transmission and reception circuitry
UCSR0C |= (1 << UCSZ00) | (1 << UCSZ01); // Use 8-bit character sizes

UBRR0H = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register
UBRR0L = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register

for (;;) // Loop forever
{
// while ((UCSR0A & (1 << RXC0)) == 0) {}; // Do nothing until data have been received and is ready to be read from UDR
// ReceivedByte = UDR0; // Fetch the received byte value into the variable "ByteReceived"

while ((UCSR0A & (1 << UDRE0)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
UDR0 = 'a'; // Echo back the received byte back to the computer
}
}

and my build details are as follows:
Code:
Build started 17.10.2011 at 09:55:29
avr-gcc  -mmcu=atmega2560 -Wall -gdwarf-2 -std=gnu99                                      -DF_CPU=8000000UL -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT Braking.o -MF dep/Braking.o.d  -c  ../Braking.c
avr-gcc -mmcu=atmega2560 -Wl,-Map=Braking.map Braking.o     -o Braking.elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature  Braking.elf Braking.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex Braking.elf Braking.eep || exit 0
avr-objdump -h -S Braking.elf > Braking.lss

AVR Memory Usage
----------------
Device: atmega2560

Program:     364 bytes (0.1% Full)
(.text + .data + .bootloader)

Data:          0 bytes (0.0% Full)
(.data + .bss + .noinit)


Build succeeded with 0 Warnings...
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits