From b4c7f34d39b214a9036611d3b3457c062883af58 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Thu, 9 Jun 2016 16:15:09 +0200 Subject: [PATCH] stc15: fix RC oscillator baudrate switch packet It looks like it wasn't correct. The last value sent is probably supposed to be the trim value for the chosen trim frequency. Addresses grigorig/stcgal#16. --- stcgal/protocols.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stcgal/protocols.py b/stcgal/protocols.py index 5668b64..316eb02 100644 --- a/stcgal/protocols.py +++ b/stcgal/protocols.py @@ -1293,7 +1293,7 @@ class Stc15Protocol(Stc15AProtocol): # This is a bit of a hack, but it works. bauds = self.baud_transfer if (self.mcu_magic >> 8) == 0xf2 else self.baud_transfer * 4 packet += struct.pack(">H", int(65535 - program_speed / bauds)) - packet += struct.pack(">H", int(65535 - (program_speed / bauds) * 1.5)) + packet += bytes(user_trim) iap_wait = self.get_iap_delay(program_speed) packet += bytes([iap_wait]) self.write_packet(packet)