microchip8_18f1220family.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. """
  2. # TOP2049 Open Source programming suite
  3. #
  4. # Microchip8 - 18f1220 family - 8bit PIC MCU
  5. #
  6. # Copyright (c) 2013 Pavel Stemberk <stemberk@gmail.com>
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License along
  19. # with this program; if not, write to the Free Software Foundation, Inc.,
  20. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. """
  22. from libtoprammer.chips.microchip8.microchip8_18_common import *
  23. class microchip8_18f1220family(Chip_Microchip8_18_common):
  24. voltageVDD = 4.5
  25. voltageVPP = 9
  26. writeBufferSize = 8
  27. eraseBufferSize = 64
  28. def __init__(self,
  29. chipPackage, chipPinVCC, chipPinsVPP, chipPinGND,
  30. signature,
  31. flashPageSize, flashPages,
  32. eepromPageSize, eepromPages,
  33. fuseBytes
  34. ):
  35. Chip_Microchip8_18_common.__init__(self,
  36. chipPackage, chipPinVCC, chipPinsVPP, chipPinGND,
  37. signature,
  38. flashPageSize, flashPages,
  39. eepromPageSize, eepromPages,
  40. fuseBytes)
  41. def erase(self):
  42. self.progressMeterInit("Erasing chip", 0)
  43. self.enterPM(True)
  44. self.executeCode(self.getCodeAddrToTBLPTR(0x3C0004))
  45. self.send4bitWriteInstruction(self.CMD_TW, 0x0080)
  46. self.executeCode((0x0000,))
  47. self.sendCommand(1)
  48. self.top.cmdDelay(self.delayP11 + self.delayP10)
  49. for i in range(0,4):
  50. self.sendCommand(1)
  51. self.top.flushCommands()
  52. self.progressMeterFinish()
  53. def setEEPROMAddr(self, addr):
  54. self.executeCode((0x0E00 | (addr & 0xFF), 0x6EA9))