Duyphi dạo này bị seo thế
. Đang định chỉ cho cái app notes AVR230 nhưng chắc đọc rồi hả.


void main(void) { unsigned char i; PULLUPPORT = PULLUPPIN; // Pull up on RX line _UBRRL = (XTAL / (16 * BAUDRATE)) - 1; //set baud rate; _UCSRB = 0x18; // Rx enable Tx Enable _UCSRC = 0x86; // Asyn,NoParity,1StopBit,8Bit #ifdef RS485DDR RS485DDR |= RS485TXE; // RS485 Tranceiver switch pin as output RS485PORT &= ~RS485TXE; // RS485 in Rx mode #endif do i = _UDR; // read and ignore data until buffer clear while(_UCSRA & 0x80); TxChar('>'); if (RxChar() == '<') { TxChar(DeviceID); TxChar(FlashSize); TxChar(BootSize); TxChar(PageSize); TxChar(EEpromSize); TxChar('!'); while (1) { GetPageNumber(); if (RealPageAddress == 0xffff) break; if (WriteFlash()) TxChar('!'); else TxChar('@'); } #ifdef EEPROM EEpromLoad(); #endif #ifdef LOCKBIT LockBit(); #endif } #ifdef RAMPZ_FLAG RAMPZ = 0; #endif #ifdef INTVECREG INTVECREG = 0x01; // Enable interrupt vector select INTVECREG = 0x00; // Move interrupt vector to flash #endif _UCSRA |= (1<<_TXC); TxChar('X'); asm("jmp 0x0000"); // Run application code }
TxChar('X');
void main(void) { unsigned char i; PULLUPPORT = PULLUPPIN; // Pull up on RX line _UBRRL = (XTAL / (16 * BAUDRATE)) - 1; //set baud rate; _UCSRB = 0x18; // Rx enable Tx Enable _UCSRC = 0x86; // Asyn,NoParity,1StopBit,8Bit #ifdef RS485DDR RS485DDR |= RS485TXE; // RS485 Tranceiver switch pin as output RS485PORT &= ~RS485TXE; // RS485 in Rx mode #endif do i = _UDR; // read and ignore data until buffer clear while(_UCSRA & 0x80); TxChar('>'); if (RxChar() == '<') { TxChar(DeviceID); TxChar(FlashSize); TxChar(BootSize); TxChar(PageSize); TxChar(EEpromSize); TxChar('!'); while (1) { GetPageNumber(); if (RealPageAddress == 0xffff) break; if (WriteFlash()) TxChar('!'); else TxChar('@'); } #ifdef EEPROM EEpromLoad(); #endif #ifdef LOCKBIT LockBit(); #endif } #ifdef RAMPZ_FLAG RAMPZ = 0; #endif #ifdef INTVECREG INTVECREG = 0x01; // Enable interrupt vector select INTVECREG = 0x00; // Move interrupt vector to flash #endif _UCSRA |= (1<<_TXC); TxChar('X'); asm("jmp 0x0000"); // Run application code }
TxChar('X');
Comment