Can now read single ended reference properly

The differencial reference values are also more reasonable now.
This commit is contained in:
meepingsnesroms
2018-07-13 08:42:34 -07:00
parent 9311ae8045
commit edb0ec8a8c
3 changed files with 15 additions and 10 deletions

View File

@@ -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);

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.6.2, 2018-07-05T10:13:54. -->
<!-- Written by QtCreator 4.6.2, 2018-07-06T09:47:00. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@@ -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