[an error occurred while processing this directive]
|
Написал вот такую прогу для Меги 16
// Mega 16
#include
#include#define XTALL 8.0
#define delay_us(us) __delay_cycles (XTALL * us)
#define NOP asm ("nop;nop;nop;")#define DataOut PORTA
#define DataIn PINA
#define DataDir DDRA#define Busy PINB_Bit0
#define OE PORTB_Bit1 // Active - Low
#define WR PORTB_Bit2 // Active - Low
#define BS1 PORTB_Bit3
#define XA0 PORTB_Bit4
#define XA1 PORTB_Bit5 // BS2
#define BS2 PORTB_Bit5 // XA1
#define XTAL1 PORTB_Bit6
#define Default 0x06//#define VCC PORTC_Bit6
#define ProgVCC PORTC_Bit7#define ProgFuse 0x40;
void main (void)
{
unsigned char i;
volatile unsigned char Data = 0;
DataDir = 0xFF;
DataOut = 0x00;
DDRC = 0xC0;
//VCC = 0;
ProgVCC = 0;
DDRB = 0x7E;
PORTB = Default;
/* Entering Prog Mode */
//VCC = 1;
for (i = 10; i >0; i--)
{
XTAL1 = 1;
NOP;
XTAL1 = 0;
};
WR = 0;
ProgVCC = 1;
delay_us(100);
/* Start Fuse Save High Byte */
PORTB = Default;
/* Load Command */
XA1 = 1;
XA0 = 0;
BS1 = 0;
DataOut = ProgFuse;
XTAL1 = 1;
NOP;
XTAL1 = 0;
PORTB = Default;
/* Setup Fuse Settings */
XA1 = 0;
XA0 = 1;
DataOut = 0xDF;
XTAL1 = 1;
NOP;
XTAL1 = 0;
PORTB = Default;
/* Save Fuse Settings */
BS1 = 1;
BS2 = 0;
WR = 0;
NOP;
WR = 1;
while (!Busy)
{
};
PORTB = Default;
/* Load Subprogramm */
/* Load Command */
XA1 = 1;
XA0 = 0;
BS1 = 0;
DataOut = 0x04;
XTAL1 = 1;
NOP;
XTAL1 = 0;
PORTB = Default;
/* Load Fuse Settings */
DataDir = 0x00;
DataOut = 0x00;
OE = 0;
BS2 = 1;
BS1 = 1;
Data = DataIn;
OE = 1;
PORTB = Default;
/* End of Prog Mode */
ProgVCC = 0;
while (1)
{
};
}
Читает нормально и Low Bits и High...
А вот писать не хочет.
Блин уже весь даташит просмотрел. Не понимаю - в чем косяк ???
В ДНК ? :-)
E-mail: info@telesys.ru