Gast
#356914
Hallo,
ich möchte bei meinem ATmega32 den Flash im Betrieb beschreiben um dort
Daten zu speichern. Versuche es mit der Funktion aus dem
avr-libc-user-manual, aber es wird infach nichts in den Flsh
geschrieben, obwohl der Code Problemlos durchläuft.
Irgendwelche Ideen?
Hier das wichtigste aus dem Code:
#define F_CPU 16000000UL
#define UART_BAUD_RATE 56000
#include <avr/io.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <avr/eeprom.h>
#include <util/delay.h>
#include <avr/boot.h>
#include <inttypes.h>
#include "uart.h"
typedef signed char int8_t;
typedef unsigned char uint8_t;
unsigned char adc_in;
unsigned char *sinus = { 0x80, 0xb0, 0xda, 0xf6, 0xff, 0xf6, 0xda,
0xb0, 0x80, 0x4f, 0x25, 0x09, 0x00, 0x09, 0x25, 0x4f,
0x80, 0xb0, 0xda, 0xf6, 0xff, 0xf6, 0xda, 0xb0, 0x80,
0x4f,
0x25, 0x09, 0x00, 0x09, 0x25, 0x4f,
0x80, 0xb0, 0xda, 0xf6, 0xff, 0xf6, 0xda, 0xb0, 0x80,
0x4f,
0x25, 0x09, 0x00, 0x09, 0x25, 0x4f,
0x80, 0xb0, 0xda, 0xf6, 0xff, 0xf6, 0xda, 0xb0, 0x80,
0x4f,
0x25, 0x09, 0x00, 0x09, 0x25, 0x4f,
0x80, 0xb0, 0xda, 0xf6, 0xff, 0xf6, 0xda, 0xb0, 0x80,
0x4f,
0x25, 0x09, 0x00, 0x09, 0x25, 0x4f,
0x80, 0xb0, 0xda, 0xf6, 0xff, 0xf6, 0xda, 0xb0, 0x80,
0x4f,
0x25, 0x09, 0x00, 0x09, 0x25, 0x4f,
0x80, 0xb0, 0xda, 0xf6, 0xff, 0xf6, 0xda, 0xb0, 0x80,
0x4f,
0x25, 0x09, 0x00, 0x09, 0x25, 0x4f,
0x80, 0xb0, 0xda, 0xf6, 0xff, 0xf6, 0xda, 0xb0, 0x80,
0x4f,
0x25, 0x09, 0x00, 0x09, 0x25, 0x4f};
void boot_program_page (uint32_t page, uint8_t *buf) {
uint16_t i;
uint8_t sreg;
// Disable interrupts.
sreg = SREG;
cli();
eeprom_busy_wait ();
boot_page_erase (page);
boot_spm_busy_wait (); // Wait until the memory is erased.
for (i=0; i<SPM_PAGESIZE; i+=2) {
// Set up little-endian word.
uint16_t w = *buf++;
w += (*buf++) << 8;
boot_page_fill (page + i, w);
}
boot_page_write (page); // Store buffer in flash page.
boot_spm_busy_wait(); // Wait until the memory is written.
// Reenable RWW-section again. We need this if we want to jump back
// to the application after bootloading.
boot_rww_enable ();
// Re-enable interrupts (if they were ever enabled).
SREG = sreg;
}
Aufruf der Funktion wie folgt: boot_program_page (3200, sinus);
Ich find den Fehler einfach nicht.
MfG
Ralf

