Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gene
xmc4500-relax-linux
Commits
e8b7a373
Commit
e8b7a373
authored
Aug 29, 2016
by
Christian Eichler
Browse files
Only enable timer overflow detection if halt debugging is disables
In addition provide that information via command "inf"
parent
cee52d31
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main.c
View file @
e8b7a373
...
...
@@ -145,6 +145,11 @@ static void command_inf(char *arg) {
default:
CDC_Device_SendString
(
&
VirtualSerial_CDC_Interface
,
"e:v
\r
"
);
break
;
}
if
(
timer_has_overflow_detection
())
{
CDC_Device_SendString
(
&
VirtualSerial_CDC_Interface
,
"o:ov e
\r
"
);
}
else
{
CDC_Device_SendString
(
&
VirtualSerial_CDC_Interface
,
"o:ov d
\r
"
);
}
if
(
PREF
->
PCON
&
PREF_PCON_IBYP_Msk
)
{
CDC_Device_SendString
(
&
VirtualSerial_CDC_Interface
,
"o:ic d
\n
"
);
...
...
src/timer.c
View file @
e8b7a373
...
...
@@ -5,16 +5,32 @@
#define CYCCNT_LIMIT (UINT32_MAX)
#define CYCCNT_INT_COST 40
static
uint32_t
overflow_counter
=
0
;
static
uint32_t
overflow_counter
=
0
;
static
bool
overflow_detection
=
false
;
void
DebugMon_Handler
()
{
++
overflow_counter
;
}
void
timer_init
()
{
bool
timer_has_overflow_detection
()
{
return
overflow_detection
;
}
bool
timer_enable_overflow_detection
()
{
if
(
CoreDebug
->
DHCSR
&
CoreDebug_DHCSR_C_DEBUGEN_Msk
)
{
return
false
;
}
DWT
->
COMP0
=
CYCCNT_LIMIT
;
DWT
->
MASK0
=
2
;
// watch 4Bytes (uint32_t)
DWT
->
FUNCTION0
=
DWT_FUNCTION_CYCMATCH_Msk
|
0x4
/* watch DWT_CYCCNT */
;
DWT
->
FUNCTION0
=
DWT_FUNCTION_CYCMATCH_Msk
|
0x4
;
// watch DWT_CYCCNT
overflow_detection
=
true
;
return
true
;
}
void
timer_init
()
{
timer_enable_overflow_detection
();
DWT
->
CYCCNT
=
0
;
// reset the counter
DWT
->
CTRL
|=
DWT_CTRL_CYCCNTENA_Msk
|
DWT_CTRL_CYCEVTENA_Msk
;
...
...
src/timer.h
View file @
e8b7a373
#ifndef __TIMER_H
#define __TIMER_H
#include
<stdbool.h>
#include
<stdint.h>
void
timer_init
();
bool
timer_enable_overflow_detection
();
bool
timer_has_overflow_detection
();
void
timer_start
();
uint64_t
timer_stop
();
#endif
/* __TIMER_H */
xmccomm.c
View file @
e8b7a373
...
...
@@ -151,6 +151,8 @@ static void resp_inf(bool success, char *resp) {
printf
(
"Frequency: %.2f%cHz"
,
freq_dbl
,
prefixes
[
idx
]);
}
else
if
(
rem
=
strsw
(
resp
,
"ic "
))
{
printf
(
"Instruction Cache: Currently %s"
,
(
'e'
==
*
rem
)
?
"enabled"
:
"disabled"
);
}
else
if
(
rem
=
strsw
(
resp
,
"ov "
))
{
printf
(
"Timer Overflow Detection: Currently %s"
,
(
'e'
==
*
rem
)
?
"enabled"
:
"disabled"
);
}
else
{
printf
(
"Unparsed: %s"
,
resp
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment