From edb0ec8a8ca05988054982906c2ffde053e08ce5 Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Fri, 13 Jul 2018 08:42:34 -0700 Subject: [PATCH] Can now read single ended reference properly The differencial reference values are also more reasonable now. --- hwTestSuite/tools.c | 20 ++++++++++++-------- qtBuildSystem/Mu/Mu.pro.user | 2 +- unimplementedHardware.txt | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hwTestSuite/tools.c b/hwTestSuite/tools.c index 8d47cd0..6b9508f 100644 --- a/hwTestSuite/tools.c +++ b/hwTestSuite/tools.c @@ -76,10 +76,10 @@ uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bi /*enable SPI 2 if disabled*/ writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4207); -#if 0 - /*send data, only send the first 6 bits to leave the ADC enabled*/ - writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config >> 2); - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4305); +#if 1 + /*send data, only send the first 5 bits to leave the ADC enabled*/ + writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config >> 3); + writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4304); while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); /*wait for the conversion to settle*/ @@ -87,11 +87,14 @@ uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bi while(wasteTime < 100) wasteTime++; - /*send last 2 bits and 1 wait bit*/ - writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config << 1); - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4302); + /*send last 3 bits, wait 1 bit, get 8/12 bit result then pad the transfer to 16 bits*/ + writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config << 14); + writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x430F); while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); -#endif + + /*get value returned*/ + value = readArbitraryMemory16(HW_REG_ADDR(SPIDATA2)) & 0x0FFF; +#else /*send data*/ writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config << 1); writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4308); @@ -104,6 +107,7 @@ uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bi /*get value returned*/ value = readArbitraryMemory16(HW_REG_ADDR(SPIDATA2)) >> (mode8bit ? 8 : 4); +#endif /*disable SPI2*/ writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0xE000); diff --git a/qtBuildSystem/Mu/Mu.pro.user b/qtBuildSystem/Mu/Mu.pro.user index 8129f28..faae2b5 100644 --- a/qtBuildSystem/Mu/Mu.pro.user +++ b/qtBuildSystem/Mu/Mu.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/unimplementedHardware.txt b/unimplementedHardware.txt index f8ca668..8c90998 100644 --- a/unimplementedHardware.txt +++ b/unimplementedHardware.txt @@ -32,7 +32,8 @@ port d IRQ* bits edge triggered interrupt mode is not emulated edgeTriggeredInterruptLastValue may need to be locked when PLL is off port d data register seems to have its data bits cleared when an edge triggered interrupt is cleared(according to MC68VZ328UM.pdf Page 10-15) Dont know if it possible to have the backlight on and the display off at the same time(theres no reason for it but it may be possible) -power button must be pushed twice to turn the CPU back on +power button must be pushed twice to turn the CPU back on(when debugging it works the first time, then must be pushed twice to turn off instead of on) +STOP opcode may be causing issues with the power button(it may be setting a separate CPU disable option) Debug tools: missing icons