Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ch32v003fun
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Horn
ch32v003fun
Commits
acf59171
Commit
acf59171
authored
10 months ago
by
cnlohr
Browse files
Options
Downloads
Patches
Plain Diff
Update notes in DMA GPIO example
parent
ad9c82e8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/dma_gpio/dma_gpio.c
+8
-4
8 additions, 4 deletions
examples/dma_gpio/dma_gpio.c
with
8 additions
and
4 deletions
examples/dma_gpio/dma_gpio.c
+
8
−
4
View file @
acf59171
// DMA GPIO Output Example - this example shows
// DMA GPIO Output Example - this example shows
// how you can output 8 pins all simultaneously
// how you can output 8 pins all simultaneously
// with a planned bit pattern at
4
MSamples/s.
// with a planned bit pattern at
2
MSamples/s.
//
//
// It outputs a pattern of repeating 010101 and
// It outputs a pattern of repeating 010101
01
and
// 00000 alternating "frames".
// 00000
0
alternating "frames".
//
//
// The interrupt fires once at the beginning and
// The interrupt fires once at the beginning and
// once at the end.
// once at the end.
...
@@ -77,6 +77,7 @@ int main()
...
@@ -77,6 +77,7 @@ int main()
(
GPIO_Speed_10MHz
|
GPIO_CNF_OUT_PP
)
<<
(
4
*
4
);
(
GPIO_Speed_10MHz
|
GPIO_CNF_OUT_PP
)
<<
(
4
*
4
);
// GPIO C All output.
// GPIO C All output.
// This is where our bitstream will be outputted to.
GPIOC
->
CFGLR
=
GPIOC
->
CFGLR
=
(
GPIO_Speed_10MHz
|
GPIO_CNF_OUT_PP
)
<<
(
4
*
0
)
|
(
GPIO_Speed_10MHz
|
GPIO_CNF_OUT_PP
)
<<
(
4
*
0
)
|
(
GPIO_Speed_10MHz
|
GPIO_CNF_OUT_PP
)
<<
(
4
*
1
)
|
(
GPIO_Speed_10MHz
|
GPIO_CNF_OUT_PP
)
<<
(
4
*
1
)
|
...
@@ -96,9 +97,11 @@ int main()
...
@@ -96,9 +97,11 @@ int main()
// DMA2 can be configured to attach to T1CH1
// DMA2 can be configured to attach to T1CH1
// The system can only DMA out at ~2.2MSPS. 2MHz is stable.
// The system can only DMA out at ~2.2MSPS. 2MHz is stable.
// The idea here is that this copies, byte-at-a-time from the memory
// into the peripheral addres.
DMA1_Channel2
->
CNTR
=
sizeof
(
memory_buffer
)
/
sizeof
(
memory_buffer
[
0
]);
DMA1_Channel2
->
CNTR
=
sizeof
(
memory_buffer
)
/
sizeof
(
memory_buffer
[
0
]);
DMA1_Channel2
->
MADDR
=
(
uint32_t
)
memory_buffer
;
DMA1_Channel2
->
MADDR
=
(
uint32_t
)
memory_buffer
;
DMA1_Channel2
->
PADDR
=
(
uint32_t
)
&
GPIOC
->
OUTDR
;
DMA1_Channel2
->
PADDR
=
(
uint32_t
)
&
GPIOC
->
OUTDR
;
// This is the output register for out buffer.
DMA1_Channel2
->
CFGR
=
DMA1_Channel2
->
CFGR
=
DMA_CFGR1_DIR
|
// MEM2PERIPHERAL
DMA_CFGR1_DIR
|
// MEM2PERIPHERAL
DMA_CFGR1_PL
|
// High priority.
DMA_CFGR1_PL
|
// High priority.
...
@@ -123,6 +126,7 @@ int main()
...
@@ -123,6 +126,7 @@ int main()
RCC
->
APB2PRSTR
=
0
;
RCC
->
APB2PRSTR
=
0
;
// Timer 1 setup.
// Timer 1 setup.
// Timer 1 is what will trigger the DMA, Channel 2 engine.
TIM1
->
PSC
=
0x0000
;
// Prescaler
TIM1
->
PSC
=
0x0000
;
// Prescaler
TIM1
->
ATRLR
=
11
;
// Auto Reload - sets period (48MHz / (11+1) = 4MHz)
TIM1
->
ATRLR
=
11
;
// Auto Reload - sets period (48MHz / (11+1) = 4MHz)
TIM1
->
SWEVGR
=
TIM_UG
|
TIM_TG
;
// Reload immediately + Trigger DMA
TIM1
->
SWEVGR
=
TIM_UG
|
TIM_TG
;
// Reload immediately + Trigger DMA
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment