Project

General

Profile

Statistics
| Revision:

esp-2014-15 / tp1g1 / 02TimerEvents / exer01.X / newmain.c @ 55

History | View | Annotate | Download (867 Bytes)

1
/*
2
 * File:   newmain.c
3
 * Author: z
4
 *
5
 * Created on September 23, 2014, 6:27 PM
6
 */
7

    
8
#include <xc.h>
9
#include <plib.h>
10
#include <stdio.h>
11
#include <stdlib.h>
12
#include <stdint.h>
13
#include "timer1.h"
14

    
15
#define SYSCLK 80000000L
16

    
17
/*
18
 *
19
 */
20
int main(int argc, char** argv) {
21
    SYSTEMConfigPerformance(SYSCLK);
22

    
23
    //variables
24
    uint16_t i, j, k = 0;
25

    
26
    TRISE = 0x00; /* PORT E: all outputs */
27

    
28
    initTimer1(1);
29
    startTimer1();
30

    
31
    while(1)
32
    {
33
        //flag is zero then output is 0xAA else is 0x55
34
        if(k == 0)
35
        {
36
            LATE = 0xAA;
37
        }
38
        else
39
        {
40
            LATE = 0x55;
41
        }
42

    
43
        //toggle da flag
44
        k = !k;
45

    
46
        /* Wait 1 seconds */
47
        while(IFS0bits.T1IF == 0)
48
        {
49
            
50
        }
51

    
52
        // Clear Timer1 flag
53
        IFS0bits.T1IF = 0;
54

    
55
    }
56

    
57
    return (EXIT_SUCCESS);
58
}
59