##############################################################################
# ADC
# (TODO)
+# see 'ADC testing stuff' section below
#
adc = usbio.ADS8201(spi0)
ota.fast = 1
ota.gain = 8
ota.offset = 0
-#arb.write()
+arb.write()
amux.selA = 48
amux.selB = 48
ota.fast = 1
ota.gain = 8
ota.offset = 0
-#amux.write()
+amux.write()
r.append(v)
print x, v
- figure()
- plot(n, r)
- xlabel('DAC code')
- ylabel('ADC count')
- title('DAC_ch0 --> ADC_ch4 direct connection')
- savefig('dac-adc-loopback.pdf')
- show()
+ if 0:
+ figure()
+ plot(n, r)
+ xlabel('DAC code')
+ ylabel('ADC count')
+ title('DAC_ch0 --> ADC_ch4 direct connection')
+ savefig('dac-adc-loopback.pdf')
+ show()
##############################################################################
# Flash testing
#
-flash = usbio.M25PExx(spi0)
-flash.power(True)
-print flash.status()
-print 'id:', str2hex(flash.id())
-print flash.status()
-print 'data:', str2hex(flash.read(0x4000, 16))
-
-flash.writeEnable(True)
-
-from intelhex import IntelHex
-#h = IntelHex('../msp4th/hello-world.hex')
-h = IntelHex('../msp4th/x.hex')
-a = [a for a in h.addresses() if (a >= 0x4000 and a < 0xf000)]
-alen = max(a) - min(a)
-#code = ''.join([chr(h[i]) for i in range(0x4000, 0x10000-2)])
-code = h.gets(0x4000, alen)
-#code = 0*'\x00' + code + '\x00\x40'
-flash.write(min(a), code)
-
-vectors = ''.join([chr(h[i]) for i in range(0xff00, 0x10000-2)])
-vectors += '\x00\x40'
-flash.write(0xff00, vectors)
-
-while not flash.isReady():
- print 'waiting...'
+if 0:
+ flash = usbio.M25PExx(spi0)
+ flash.power(True)
+ print flash.status()
+ print 'id:', str2hex(flash.id())
+ print flash.status()
+ print 'data:', str2hex(flash.read(0x4000, 16))
+
+ flash.writeEnable(True)
+
+ from intelhex import IntelHex
+ #h = IntelHex('../msp4th/hello-world.hex')
+ h = IntelHex('../msp4th/x.hex')
+
+ #code space in RAM, only get/send used block of bytes
+ a = [a for a in h.addresses() if (a >= 0x4000 and a < 0xff00)]
+ alen = max(a) - min(a)
+ code = h.gets(0x4000, alen)
+ flash.write(min(a), code)
+
+ # 0xffd0 -- 0xffff are interrupt vectors
+ # gcc et.al. for some reason do not give a value for 0xfffe word
+ # the flash loader in ROM jumps to addr pointed here
+ # force to start of RAM
+ #
+ # the flash uses 256-byte pages, include code from 0xff00 - 0xffcf
+ # as it was excluded above
+ vectors = ''.join([chr(h[i]) for i in range(0xff00, 0x10000-2)])
+ vectors += '\x00\x40'
+ flash.write(0xff00, vectors)
+
+ while not flash.isReady():
+ print 'waiting...'
if 0:
nread = 0
def pinState(self, bitfield):
"""Set GPIO pins to given bitfield state, ignoring scl/sda pins."""
- b = intbv(bitfield, max=2**8)
- b[self.scl] = self.io[self.scl]
- b[self.sda] = self.io[self.sda]
+ bits = intbv(bitfield, max=2**8)
+ bits[self.scl] = self.io[self.scl]
+ bits[self.sda] = self.io[self.sda]
print 'port:', b(self.port, 8), '-->',
- self.port[:] = d
+ self.port[:] = bits
print b(self.port, 8)
ftdi.write_data(self.context, chr(self.port), 1)