Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

About boot loader at mega128

Status
Not open for further replies.

fateme91

Member level 2
Joined
Nov 18, 2014
Messages
48
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Location
Iran,Mashad
Activity points
349
Hi
I need to work with boot loader of ATmega128.
what is cvmegaload? do u have the program ?
DO u have an example ?
 

i think you can change the mcu clock in the atmega128.h file where _MCU_CLOCK_FREQUENCY_ is defined
 

Can u give me a usart program that micro sends 'A' and then recieves 'B' by usart connection.
My program worked before but now it does not.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include <mega128a.h>
#include <stdio.h>
#include <stdlib.h>
 
 
 
#ifndef RXB8
#define RXB8 1
#endif
 
#ifndef TXB8
#define TXB8 0
#endif
 
#ifndef UPE
#define UPE 2
#endif
 
#ifndef DOR
#define DOR 3
#endif
 
#ifndef FE
#define FE 4
#endif
 
#ifndef UDRE
#define UDRE 5
#endif
 
#ifndef RXC
#define RXC 7
#endif
 
#define FRAMING_ERROR (1<<FE)
#define PARITY_ERROR (1<<UPE)
#define DATA_OVERRUN (1<<DOR)
#define DATA_REGISTER_EMPTY (1<<UDRE)
#define RX_COMPLETE (1<<RXC)
 
// USART0 Receiver buffer
#define RX_BUFFER_SIZE0 8
char rx_buffer0[RX_BUFFER_SIZE0];
 
#if RX_BUFFER_SIZE0 <= 256
unsigned char rx_wr_index0,rx_rd_index0,rx_counter0;
#else
unsigned int rx_wr_index0,rx_rd_index0,rx_counter0;
#endif
 
// This flag is set on USART0 Receiver buffer overflow
bit rx_buffer_overflow0;
 
// USART0 Receiver interrupt service routine
interrupt [USART0_RXC] void usart0_rx_isr(void)
{
char status,data;
status=UCSR0A;
data=UDR0;
if ((status & (FRAMING_ERROR | PARITY_ERROR | DATA_OVERRUN))==0)
   {
   rx_buffer0[rx_wr_index0++]=data;
#if RX_BUFFER_SIZE0 == 256
   // special case for receiver buffer size=256
   if (++rx_counter0 == 0) rx_buffer_overflow0=1;
#else
   if (rx_wr_index0 == RX_BUFFER_SIZE0) rx_wr_index0=0;
   if (++rx_counter0 == RX_BUFFER_SIZE0)
      {
      rx_counter0=0;
      rx_buffer_overflow0=1;
      }
#endif
   }
}
 
#ifndef _DEBUG_TERMINAL_IO_
// Get a character from the USART0 Receiver buffer
#define _ALTERNATE_GETCHAR_
#pragma used+
char getchar(void)
{
char data;
while (rx_counter0==0);
data=rx_buffer0[rx_rd_index0++];
#if RX_BUFFER_SIZE0 != 256
if (rx_rd_index0 == RX_BUFFER_SIZE0) rx_rd_index0=0;
#endif
#asm("cli")
--rx_counter0;
#asm("sei")
return data;
}
#pragma used-
#endif
 
// USART0 Transmitter buffer
#define TX_BUFFER_SIZE0 8
char tx_buffer0[TX_BUFFER_SIZE0];
 
#if TX_BUFFER_SIZE0 <= 256
unsigned char tx_wr_index0,tx_rd_index0,tx_counter0;
#else
unsigned int tx_wr_index0,tx_rd_index0,tx_counter0;
#endif
 
// USART0 Transmitter interrupt service routine
interrupt [USART0_TXC] void usart0_tx_isr(void)
{
if (tx_counter0)
   {
   --tx_counter0;
   UDR0=tx_buffer0[tx_rd_index0++];
#if TX_BUFFER_SIZE0 != 256
   if (tx_rd_index0 == TX_BUFFER_SIZE0) tx_rd_index0=0;
#endif
   }
}
 
#ifndef _DEBUG_TERMINAL_IO_
// Write a character to the USART0 Transmitter buffer
#define _ALTERNATE_PUTCHAR_
#pragma used+
void putchar(char c)
{
while (tx_counter0 == TX_BUFFER_SIZE0);
#asm("cli")
if (tx_counter0 || ((UCSR0A & DATA_REGISTER_EMPTY)==0))
   {
   tx_buffer0[tx_wr_index0++]=c;
#if TX_BUFFER_SIZE0 != 256
   if (tx_wr_index0 == TX_BUFFER_SIZE0) tx_wr_index0=0;
#endif
   ++tx_counter0;
   }
else
   UDR0=c;
#asm("sei")
}
#pragma used-
#endif
 
// Standard Input/Output functions
#include <stdio.h>
 
// Declare your global variables here
 
void main(void)
{
unsigned char h;
char data;
char a[10];
 
PORTD=0x00;
DDRD=0x01;
 
// USART0 initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART0 Receiver: On
// USART0 Transmitter: On
// USART0 Mode: Asynchronous
// USART0 Baud Rate: 9600
UCSR0A=0x00;
UCSR0B=0xD8;
UCSR0C=0x06;
UBRR0H=0x00;
UBRR0L=0x67;
 
 
#asm("sei")
 
putchar ('A');
 
 
 
 
while (1)
      { 
      if (data=='A')
      {
            a=='B';
            gets (a,10);
      }
            
      
      
      }
}



Another one: Haow can i assign the content of putchar in a variable?
data=putchar ('A') ; it's not right ...
 
Last edited:

you code looks hmm ok but if it before working and now its not working then check your hardware cable connection.

Code:
#include 
#include 
#include 

#define xtal 4000000L
#define baud 9600

char get_data(void)
{
	while((UCSR0A & RXC) == 0)
			;
			return UDR0;
}

void put_data(char c)
{
while((UCSR0A & UDRE0) == 0)
		;
		UDR0 =c;
}

void main(void)
{
	char k;

	UBRR0L=xtal/16/baud-1;

	UCSR0B= ((1<<RXEN0)|(1<<TXEN0));

	while(1)
	{
	k = get_data();
	put_data(k);
	};
}

just simple echo code that might help change your clock frequency as per your settings
 
How this program MEgaload work?
there is no button for start or ok or sth like that...

1.jpg
 

Yes, apparently starting automatically after opening flash file. It says "waiting for target".
 
Now it writes : Error accured.
Do u have a file which explain errors of megaload?

Thank you...
2323.jpg
 

Attachments

  • 2323.jpg
    2323.jpg
    123.6 KB · Views: 101

Sending page #0 multiple times means that it's either not correctly processed by the bootloader or there's a connection problem.

Did you understand the requirements for an application used together with a bootloader?
 
Hi
i checked the connections but there is no problem. a rs232 cable with max232. What do u mean " the requirements for an application used together with a bootloader? "




Sending page #0 multiple times means that it's either not correctly processed by the bootloader or there's a connection problem.

Did you understand the requirements for an application used together with a bootloader?

- - - Updated - - -

Tnks but i didnot get my answer....


 

I think respected FvM sir means did you know that your application really need a bootloader programming.He means Bootloader is used when you need to update your application firmware on the feild or many updates is required in application firmware .Does your application need that? correct me If I am wrong FvM sir
 

Tnks but i didnot get my answer....



Common error.
-
Wrong fuse bit setting, «Boot on reset, Boot size, Speed» .
-
Wrong setting in ICCAVR option menu.
-
Forget to define your MCU in the assembly.s file.
-
Use the monitor windows in MegaLoad to see if there is communication.
-
If you only need flash programing don’t set the fusebit programing on.
-
If you only need flash programing don’t set the eeprom programing on.
-
See and check above any might be problem and this was mentioned in the tutorial.
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
My application is so simple. i want a led turns on and off. i need bootloader to reach programming without external programmer.


I think respected FvM sir means did you know that your application really need a bootloader programming.He means Bootloader is used when you need to update your application firmware on the feild or many updates is required in application firmware .Does your application need that? correct me If I am wrong FvM sir

- - - Updated - - -

it writes:
Sending page#0
flash fail



Common error.
-
Wrong fuse bit setting, «Boot on reset, Boot size, Speed» .
-
Wrong setting in ICCAVR option menu.
-
Forget to define your MCU in the assembly.s file.
-
Use the monitor windows in MegaLoad to see if there is communication.
-
If you only need flash programing don’t set the fusebit programing on.
-
If you only need flash programing don’t set the eeprom programing on.
-
See and check above any might be problem and this was mentioned in the tutorial.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top