Skip to content

Commit 4102435

Browse files
committed
bug: fix interrupt-driven oscilloscope capture
1 parent 978352f commit 4102435

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pslab-core.X/instruments/oscilloscope.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ static void Capture(void) {
5858
SetBUFFER_IDX(i, &BUFFER[i * GetSAMPLES_REQUESTED()]);
5959
}
6060

61+
SetCONVERSION_DONE(0);
6162
SetSAMPLES_CAPTURED(0);
6263
SetBUFFER_IDX(0, &BUFFER[0]);
6364
SetTimeGap();
65+
ADC1_InterruptFlagClear();
66+
ADC1_InterruptEnable();
6467
LED_SetLow();
6568
}
6669

@@ -82,7 +85,8 @@ response_t OSCILLOSCOPE_CaptureDMA(void) {
8285
DMA_InterruptEnable(DMA_CHANNEL_0);
8386
DMA_ChannelEnable(DMA_CHANNEL_0);
8487

85-
SetSAMPLES_CAPTURED(GetSAMPLES_REQUESTED()); // Assume it's all over already.
88+
SetSAMPLES_CAPTURED(GetSAMPLES_REQUESTED());
89+
SetCONVERSION_DONE(1); // Assume it's all over already.
8690
SetTimeGap();
8791
LED_SetLow();
8892

pslab-core.X/registers/converters/adc1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static uint16_t DELAY;
6161
void SetDELAY(uint16_t V) { DELAY = V; }
6262
uint16_t GetDELAY(void) { return DELAY; }
6363

64-
static uint8_t CONVERSION_DONE = 1;
64+
static uint8_t volatile CONVERSION_DONE = 1;
6565
void SetCONVERSION_DONE(uint8_t V) { CONVERSION_DONE = V; }
6666
uint8_t GetCONVERSION_DONE(void) { return CONVERSION_DONE; }
6767

0 commit comments

Comments
 (0)