Guten Tag,
folgendes Programm erzeugt ein Lauflicht (links/rechts/links/rechts/...)
am PORTC (RC0, RC1, RC2, RC3, RC4, RC5, RC6, RC7) des EasyPICv7.
Es erfolgt eine ständige Überprüfung ob TRISC als OUTPUT gesetzt ist.
Ist dies nicht der Fall, wird ein Wechselblinker am PORTE (RE1, RE2)
aktiv.
1 | int ports(void)
|
2 | {
|
3 | TRISC = 0x00; // set direction to be output
|
4 | TRISE = 0x00; // set direction to be output (output error)
|
5 |
|
6 | LATC = 0x00; // turn OFF the LATC leds
|
7 | LATE = 0x00; // turn OFF the LATD leds (output error)
|
8 |
|
9 | if( TRISC != 0x00)
|
10 | {
|
11 | return -1;
|
12 | }
|
13 | else
|
14 | {
|
15 | return 0;
|
16 | }
|
17 | }
|
18 |
|
19 | void main()
|
20 | {
|
21 | int flag;
|
22 | char i;
|
23 |
|
24 | flag = ports();
|
25 |
|
26 | if(flag == 0)
|
27 | {
|
28 | while(1)
|
29 | {
|
30 | for(i = 0; i < 8; i ++)
|
31 | {
|
32 | Delay_ms(30);
|
33 | LATC = 0x01 << i;
|
34 | }
|
35 | for(i = 7; i > 0; i --)
|
36 | {
|
37 | Delay_ms(30);
|
38 | LATC = 0x01 << i;
|
39 | }
|
40 | }
|
41 | }
|
42 |
|
43 | if(flag == -1)
|
44 | {
|
45 | while(1)
|
46 | {
|
47 | {
|
48 | Delay_ms(100);
|
49 | LATE = 0x01 << 1;
|
50 | Delay_ms(100);
|
51 | LATE = 0x01 << 2;
|
52 | }
|
53 | }
|
54 | }
|
55 | }
|
Den selben Effekt, möchte ich jetzt mit interrupts und dem Oscillator
erzielen. Wer kann mir dabei helfen?
Vielen Dank im Voraus!