From d48a15b628b517aab47beefed4552da329cb0070 Mon Sep 17 00:00:00 2001 From: Pavel Štemberk Date: Fri, 4 Oct 2013 20:33:11 +0200 Subject: Add more Microchip implementations Signed-off-by: Michael Buesch --- .../microchip8_splittedPMarea_hasResetPC.py | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 libtoprammer/chips/microchip8/microchip8_splittedPMarea_hasResetPC.py (limited to 'libtoprammer/chips/microchip8/microchip8_splittedPMarea_hasResetPC.py') diff --git a/libtoprammer/chips/microchip8/microchip8_splittedPMarea_hasResetPC.py b/libtoprammer/chips/microchip8/microchip8_splittedPMarea_hasResetPC.py new file mode 100644 index 0000000..b7bd991 --- /dev/null +++ b/libtoprammer/chips/microchip8/microchip8_splittedPMarea_hasResetPC.py @@ -0,0 +1,72 @@ +""" +# TOP2049 Open Source programming suite +# +# pic8_splittedPMarea - file for newer 8bit PIC MCUs +# +# Copyright (c) 2013 Pavel Stemberk +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +from libtoprammer.chips.microchip8.microchip8_splittedPMarea import * + +class microchip8_splittedPMarea_hasResetPC(microchip8_splittedPMarea): + + CMD_RESET_ADDRESS = 0x16 + + userIDLocationSize = 4 + voltageVDD = 3 + voltageVPP = 8.5 + + logicalFlashProgramMemorySize = 0x8000 + logicalFlashConfigurationMemorySize = 0x8000 + + def __init__(self, + chipPackage, chipPinVCC, chipPinsVPP, chipPinGND, + signature, + flashPageSize, flashPages, + eepromPageSize, eepromPages, + fuseBytes + ): + microchip8_splittedPMarea.__init__(self, chipPackage, chipPinVCC, chipPinsVPP, chipPinGND, signature, flashPageSize, flashPages, eepromPageSize, eepromPages, fuseBytes) + + def setPC(self, address): + if(self.isInsideProgramMemoryArea): + if(address >= self.logicalFlashProgramMemorySize): + raise(TOPException('Cannot set PC to address inside PM {:x}'.format(address))) + if(address < self.PC): + self.resetPC() + self.setPC(address) + else: + if(address < self.logicalFlashProgramMemorySize): + raise(TOPException('Cannot set PC to address outside PM {:x}'.format(address))) + if(address < self.PC): + self.resetPC() + self.enterConfigArea() + self.setPC(address) + while(self.PC != address): + self.incrementPC(1) + + def resetPC(self): + if hasattr(self, 'osccalAddr'): + if not hasattr(self, 'CMD_RESET_ADDRESS'): + print("reset instruction is not supported") + self.exitPM() + self.enterPM() + else: + self.sendCommand(0, 0, 0, self.CMD_RESET_ADDRESS) + self.PC = 0 + self.isInsideProgramMemoryArea = True + -- cgit v1.2.3