Skip to content

Commit

Permalink
Fix: use delayed write flash page in AvrIspProtocol
Browse files Browse the repository at this point in the history
This MR is about fixing the AvrIspProtocol.write_flash_page() by using the delayed write command with an optional delay parameter.
A delayed write page flash is prefered over normal write command in terms of being in sync with MCU's flash memory timing constraints.
See this issue  for further details :  microchip-pic-avr-tools/pymcuprog#44
  • Loading branch information
araqioui committed Apr 18, 2024
1 parent 9bbeceb commit 5fba457
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyedbglib/protocols/avrispprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def write_lockbits(self, data):
command.extend(data)
self._spi_cmd_resp(command)

def write_flash_page(self, byte_address, data):
def write_flash_page(self, byte_address, data, delay_ms = 5):
"""
Writes a page of flash
Expand All @@ -277,8 +277,8 @@ def write_flash_page(self, byte_address, data):
self.load_address(byte_address >> 1)
command = bytearray([AvrIspProtocol.SPI_CMD_PROGRAM_FLASH])
command.extend(binary.pack_be16(len(data)))
command.extend([0x81]) # Page mode
command.extend([0]) # Not used
command.extend([0x91]) # Write page with timed delay
command.extend([delay_ms])
command.extend([AvrIspProtocol.AVR_LOAD_PAGE_COMMAND])
command.extend([AvrIspProtocol.AVR_WRITE_PAGE_COMMAND])
command.extend([0]) # Not used
Expand Down

0 comments on commit 5fba457

Please sign in to comment.