Project

General

Profile

Statistics
| Revision:

esp-2014-15 / tp1g3 / Aula1_ex1.X / main.c @ 91

History | View | Annotate | Download (1.04 KB)

1
/**
2
 * *****************************************************************************
3
 * @file    timers.h
4
 * @author  TP1G3
5
 * @version V1.0
6
 * @date    Sep 2014
7
 * @brief   Simple I/O exercise 1
8
 * *****************************************************************************
9
 *
10
 *                   2014 UNIVERSIDADE DE AVEIRO
11
 */
12
#include <stdio.h>
13
#include <stdlib.h>
14
#include <stdint.h>
15
#include <xc.h>
16

    
17
/*functions created*/
18
void config_dev(void);      // function to configure de device
19
void delay_function(void);   // delay function
20
/*
21
 * 
22
 */
23
int main(int argc, char** argv) {
24
    config_dev();
25

    
26
    LATB = 0xAA;                    // Initial value at the output 0xAA
27
    delay_function();
28
    while(1){
29
        LATB = ~LATB;               // Inverts the output
30
        delay_function();           // wait some time
31
    }
32

    
33
    return (EXIT_SUCCESS);
34
}
35

    
36
void config_dev(){
37
    TRISB = 0;          // define all PORTB pins as output
38
}
39

    
40
void delay_function(){
41
    uint16_t i,j;
42

    
43
    for(i=0;i<10000;i++){
44
        for(j=0;j<500;j++)
45
            asm("nop");
46
    }
47

    
48
}