<@U0175T39732> just posted an update to the carave...
# mpw-2-silicon
j
@Matthew Guthaus just posted an update to the caravel_board repo that supports
make change_power VOLTAGE=<v>
from the gpio_test directory. this will change power without resetting the processor so can be modified after configuring IO. you will need to pull and run
make F746ZG-copy
from the nucleo directory before using.
👍 3
m
Looking closer, I knew how to do this in micropython, but the question is how to do it in a custom firmware. For example, once I generate the gpio_config_data.c, this runs at a given voltage and my user test will then continue running at that voltage. It seems like we need to write the I2C bus in our C code like this Python code:
Copy code
# Note:
          # Potentiometer is MCP4661 and has 10k ohms in
          # 257 steps = 38.9 ohms/step.
          # LDO is MIC2211, which has an output equal to
          # R1 = R2 * (Vout / 1.25 - 1)
          # Where R1 is between Vout and Adj and
          # R2 is between Adj and ground.
          # The caravel board has R1 = 360 and
          # R2 = 5k // (500 + potentiometer value)

          R2 = 360 / ((self.voltage / 1.25) - 1)
          Rpot = (1 / (1 / R2 - 1 / 5000)) - 500
          P = Rpot / 38.911
          Pval = int(P)

          # print('Writing ' + str(Pval) + ' to potentiometer.')
          self.supply.write_1v8(Pval)

      def write_1v8(self, value):
          self.i2c.write_byte(0x50, start=True, stop=False)
          self.i2c.write_byte(0x10 & value >> 8, start=False, stop=False)
          ack = self.i2c.write_byte(value & 0xFF, start=False, stop=True)
          return ack