-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
39 lines (32 loc) · 1.32 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* parpadeo de un led (RA1) a 100ms asiendo uso de interrupciones y timers por software.
* solo carga el programa y listo e led ya esta en tu tarjeta, conectado al pin RA1.
* por default la velocidad de ejecucion seria de 12MHz
*/
#include <xc.h>
#include "fuses.h"
#include "types.h"
#include "gpios/gpios.h"
#include "system/system.h"
#include "swtimers/swtimers.h"
int main(void)
{
ANCON0 = 0XFF; /*Desactivamos las entradas analogicas*/
ANCON1 = 0XFF; /*Desactivamos las entradas analogicas*/
Timers_Init(); /*inicializamos el driver para genere una interrupcion cada 5ms*/
Timers_SetTime(0, 100/timers_ms); /*recargamos el canal 0 con un valor de 100ms*/
Gpios_PinDirection(GPIOS_PORTA, 1, GPIOS_OUTPUT); /*puerto RA1 como salida*/
__ENABLE_INTERRUPTS(); /*se habilitan las interrupciones globales con prioridad*/
while (1)
{
if(Timers_u16GetTime(0) == 0)/*preguntamos si la interrupcion decrmento hasta llegar a 0 el canal 0*/
{
Timers_SetTime(0, 100/timers_ms);/*se cumplen los 100ms asi que volvemos a recargar el mismo canal */
Gpios_TogglePin(GPIOS_PORTA, 1); /*invierto el estado del led conectado al puerto A pin 1*/
}
}
}
void interrupt low_priority low_isr( void )
{
Timers_Isr();
}