Bläddra i källkod

Add saturate instruction

Use ARM's unsigned saturate instruction to limit the value, to be written to DAC, to 11 bits (range 0 to 4095).
teensy4-core
shkshk90 6 år sedan
förälder
incheckning
edc3f0c12b
Inget konto är kopplat till bidragsgivarens mejladress
1 ändrade filer med 3 tillägg och 3 borttagningar
  1. +3
    -3
      teensy3/analog.c

+ 3
- 3
teensy3/analog.c Visa fil

@@ -524,7 +524,7 @@ void analogWriteDAC0(int val)
} else {
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; // 3.3V VDDA is DACREF_2
}
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val));
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val)); // 0 <= val <= 4095

*(volatile aliased_int16_t *)&(DAC0_DAT0L) = val;
#elif defined(__MKL26Z64__)
@@ -536,7 +536,7 @@ void analogWriteDAC0(int val)
// use whatever voltage is on the AREF pin
DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACSWTRG; // 3.3V VDDA
}
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val));
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val)); // 0 <= val <= 4095

*(volatile aliased_int16_t *)&(DAC0_DAT0L) = val;
#endif
@@ -552,7 +552,7 @@ void analogWriteDAC1(int val)
} else {
DAC1_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; // 3.3V VDDA is DACREF_2
}
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val));
__asm__ ("usat %[value], #12, %[value]\n\t" : [value] "+r" (val)); // 0 <= val <= 4095

*(volatile aliased_int16_t *)&(DAC1_DAT0L) = val;
}

Laddar…
Avbryt
Spara