C8051F32x firmware infrastructure
Sign in or create your account | Project List | Help
C8051F32x firmware infrastructure Git Source Tree
Root/
| 1 | /* |
| 2 | * example/example.c - Example application |
| 3 | * |
| 4 | * Written 2010 by Werner Almesberger |
| 5 | * Copyright 2010 Werner Almesberger |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | |
| 16 | #include "regs.h" |
| 17 | |
| 18 | |
| 19 | static void count(void) |
| 20 | { |
| 21 | union { |
| 22 | uint32_t n; |
| 23 | uint8_t a[3]; |
| 24 | } c; |
| 25 | |
| 26 | c.n = 0; |
| 27 | while (1) { |
| 28 | P0 = c.a[0]; |
| 29 | P2 = c.a[1]; |
| 30 | P3 = c.a[2]; |
| 31 | c.n++; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | |
| 36 | void main(void) |
| 37 | { |
| 38 | /* |
| 39 | * VDD monitor enable sequence, section 7.2 |
| 40 | * |
| 41 | * - enable voltage monitor |
| 42 | * - wait for monitor to stabilize |
| 43 | * - enable VDD monitor reset |
| 44 | */ |
| 45 | |
| 46 | VDM0CN = VDMEN; |
| 47 | while (!(VDM0CN & VDDSTAT)); |
| 48 | RSTSRC = PORSF; |
| 49 | |
| 50 | /* |
| 51 | * Go to 24 Mhz |
| 52 | */ |
| 53 | OSCICN |= IFCN0 | IFCN1; |
| 54 | |
| 55 | count(); |
| 56 | } |
| 57 |
Branches:
master
