Skip to content

Commit e8d93ec

Browse files
committed
more comments added
1 parent 62a5184 commit e8d93ec

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

pwm/stm32-pwm.c

+8-19
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,6 @@ volatile uint32_t dma_stream_complete = 0;
4949
uint8_t dmaStream = DMA_STREAM1;
5050
uint32_t dmaChannel = DMA_SxCR_CHSEL_6;
5151
uint32_t dmaUnit = DMA2;
52-
53-
/*
54-
volatile uint32_t timer2Ticks = 0;
55-
volatile uint16_t tim1_dier= 0;
56-
volatile uint16_t tim1_dcr= 0;
57-
volatile uint16_t tim1_cr1= 0;
58-
volatile uint16_t tim1_cr2= 0;
59-
volatile uint16_t tim1_sr = 0;
60-
volatile uint16_t tim1_egr = 0;
61-
volatile uint32_t tim1_ccr1 = 0;
62-
volatile uint32_t tim1_ccr2 = 0;
63-
volatile uint32_t tim1_ccr3 = 0;
64-
volatile uint32_t tim1_ccr4 = 0;
65-
volatile uint32_t dma2_stream1_spar = 0;
66-
volatile uint32_t dma2_stream1_moar = 0;
67-
volatile uint32_t dma2_stream1_ndtr = 0;
68-
*/
69-
70-
//const uint16_t dma_buffer[] = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200 }; // Initial duty cycle
7152
//
7253
// sequence of values easily recognizable on a scope
7354
const uint16_t dma_buffer[] = { 100, 350, 500, 350 };
@@ -236,21 +217,29 @@ int main(void) {
236217
nvic_enable_irq(NVIC_DMA2_STREAM1_IRQ);
237218

238219
while(1) {
220+
//
221+
// report back that dma is working by generating 5 flashes
239222
flashes = dma_stream_complete > 0 ? 5:1;
240223
offTime = 3000 - (flashes*(onTime+shortOffTime));
241224
if (systicks > ticks) {
242225
//
243226
// period elapsed
244227
if (duration == shortOffTime && ++flashCount == flashes) {
228+
//
229+
// number of short flashes reached, start over with long time off
245230
duration = offTime;
246231
gpio_set(GPIOC, GPIO13);
247232
flashCount = 0;
248233
}
249234
else if (duration == onTime) {
235+
//
236+
// end of short flash reached, start over with short time off
250237
duration = shortOffTime;
251238
gpio_set(GPIOC, GPIO13);
252239
}
253240
else if (duration == shortOffTime) {
241+
//
242+
// end of short time off reached, tart over with short time on
254243
duration = onTime;
255244
gpio_clear(GPIOC, GPIO13);
256245
}

0 commit comments

Comments
 (0)