2021-03-07 18:24:42 +01:00
|
|
|
/* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
2021-03-27 18:23:58 +01:00
|
|
|
|
|
|
|
#include <nuvoton/functions.h>
|
|
|
|
#include <nuvoton/N76E003.h>
|
|
|
|
#include <nuvoton/Common.h>
|
|
|
|
#include <nuvoton/Delay.h>
|
|
|
|
#include <nuvoton/SFR_Macro.h>
|
2021-03-07 18:24:42 +01:00
|
|
|
|
|
|
|
// 16Mhz clock
|
|
|
|
#define CLOCK 16000000L
|
|
|
|
// Divide by 12
|
|
|
|
#define T0CLOCK ((CLOCK)/12L)
|
|
|
|
// Per milisecond
|
|
|
|
#define T0_1MS ((T0CLOCK)/1000L)
|
|
|
|
|
2021-03-27 18:23:58 +01:00
|
|
|
static void msdelay(unsigned long int count)
|
2021-03-07 18:24:42 +01:00
|
|
|
{
|
2021-03-27 18:23:58 +01:00
|
|
|
int reload = -T0_1MS;
|
2021-03-07 18:24:42 +01:00
|
|
|
|
|
|
|
// Input = Fsys/12
|
2021-03-27 18:23:58 +01:00
|
|
|
clr_T0M;
|
2021-03-07 18:24:42 +01:00
|
|
|
// Mode 1
|
2021-03-27 18:23:58 +01:00
|
|
|
set_GATE_T0;
|
2021-03-07 18:24:42 +01:00
|
|
|
|
|
|
|
// Start
|
|
|
|
TR0 = 1;
|
|
|
|
while (count != 0)
|
|
|
|
{
|
|
|
|
TL0 = reload & 0xFF;
|
|
|
|
TH0 = reload >> 8 & 0xFF;;
|
|
|
|
|
|
|
|
while(!TF0);
|
|
|
|
TF0 = 0;
|
|
|
|
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
TR0 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
// Set pins in old-skool Quasi Bidirectional mode
|
|
|
|
P0M1 = 0;
|
|
|
|
P0M2 = 0;
|
|
|
|
P1M1 = 0;
|
|
|
|
P1M2 = 0;
|
|
|
|
P3M1 = 0;
|
|
|
|
P3M2 = 0;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
P01 = 0;
|
|
|
|
P13 = 0;
|
|
|
|
msdelay(500);
|
|
|
|
P01 = 0;
|
|
|
|
P13 = 0;
|
|
|
|
msdelay(500);
|
|
|
|
P01 = 0;
|
|
|
|
P13 = 0;
|
|
|
|
msdelay(500);
|
|
|
|
P01 = 0;
|
|
|
|
P13 = 0;
|
|
|
|
msdelay(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|