- ページ 3
マイクロコントローラ Digilent PmodHB5のPDF リファレンス・マニュアルをオンラインで閲覧またはダウンロードできます。Digilent PmodHB5 4 ページ。
PmodHB5: Demo
Resources Used
Timer5 configuration is done using Plib macros in AppInit function. SFRs approach is also provided in
the commented code.
Plib macro used:
OpenTimer5(T5_ON | T5_SOURCE_INT | T5_PS_1_8, 99);
ConfigIntTimer5(T5_INT_ON | T5_INT_PRIOR_7 | T5_INT_SUB_PRIOR_3);
Meaning:
- T5_ON – timer 5 is ON.
- T5_PS_1_8 (Prescaler 1/8): so the frequency is 1/8 of Peripheral bus freq, which is 1/8 of SYSCLK
(65 MHz) = 1 MHz
- Period = 99, so Timer period = (99 + 1) * 1/1MHz = 100 us
- T5_SOURCE_INT : Timer5 triggers interrupt
- T5_INT_ON – T5 interrupt is ON
- T5_INT_PRIOR_7, T5_INT_SUB_PRIOR_3 - timer interrupt priority level 7, subpriority level 3
More information about Timer5 is shown in Timer5Handler.
Functions defined in main.c
void __ISR(_TIMER_5_VECTOR, ipl7) Timer5Handler(void)
Parameters:
none
Interrupt service routine for Timer 5 interrupt. Programmed to execute every 100 us. It is
used to:
1. perform software debouncing of the on-board buttons and detect:
-
-
2. to increment the real time counter
3. as a time base for clearing the action LEDs (LD3 and LD2)
4. as a time base for updating the display
int main(void)
Parameters:
none
Performs basic board initialization and then enters the main program loop.
void Display(double dDuty)
Parameters:
dDuty - the applied duty (between -1 and 1), negative values correspond to the
negative direction of motion, while positive numbers correspond to the positive
direction of motion.
www.digilentinc.com
Copyright Digilent, Inc. All rights reserved. Other product and company names mentioned may be trademarks of their respective owners.
single button situation: when a button should be processed (being pressed or
being kept pressed)
double buttons situation: when a button is released while the other is pressed
Digilent, Inc.
page 3 of 4