Алеее ! ! ! Ну может быть не записывает потому что int вести 16 а char 8 ???? Почему же не работает ?? Горит светодиод, если S=1...
CODE:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/delay.h>
#define F_CPU 8000000UL
unsigned char S=1;
unsigned char F=3;
unsigned char A;
void EEPROM_write(unsigned int uiAddress, unsigned char ucData)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEWE))
;
/* Set up Address and Data Registers */
EEAR = uiAddress;
EEDR = ucData;
/* Write logical one to EEMWE */
EECR |= (1<<EEMWE);
/* Start eeprom write by setting EEWE */
EECR |= (1<<EEWE);
}
unsigned char EEPROM_read(unsigned int uiAddress)
{
/* Wait for completion of previous write */
while(EECR & (1<<EEWE))
;
/* Set up Address Register */
EEAR = uiAddress;
/* Start eeprom read by writing EERE */
EECR |= (1<<EERE);
/* Return data from Data Register */
return EEDR;
}
int main(void)
{
DDRA = 0xff;
DDRC = 0x00;
PORTC= 0b01;
PORTA=0x0, PORTA |= 1<<0;
_delay_ms(10);
sei();
EEPROM_write(0x3E, F);
A=EEPROM_read(0x3E);
if (A>2) S=A;
while(1)
{
if (S==1) PORTA=0x0, PORTA |= 1<<0;
if (S==2) PORTA=0x0, PORTA |= 1<<1;
if (S==3) PORTA=0x0, PORTA |= 1<<2;
if (S==4) PORTA=0x0, PORTA |= 1<<3;
if (S==5) PORTA=0x0, PORTA |= 1<<4;
if (S==6) PORTA=0x0, PORTA |= 1<<5;
if (S>6) PORTA=0xff;
}
}
Отредактировано модератором: бот_м_16, 02 Февраля, 2010 - 18:26:47 есть тег для кода! |