4,11 → 4,11 |
#include "main.h" |
#use i2c(SLAVE,Fast,sda=PIN_C4,scl=PIN_C3,force_hw,address=0xA2) // Motor 2 |
|
#include <time.h> //standard C time library |
#include <rtctimer.c> //library for time.h that uses timer2 as time base |
//#include <time.h> //standard C time library |
//#include <rtctimer.c> //library for time.h that uses timer2 as time base |
|
#include <stdlib.h> |
#include <input.c> //needed for the rs232 input routines |
//#include <stdlib.h> |
//#include <input.c> //needed for the rs232 input routines |
|
|
int16 count=0xA5A5; |
70,7 → 70,7 |
output_toggle(PIN_E0); |
} |
|
#int_TIMER0 //pro preteceni \u010díta\u010de p\u016flz\u016f od anemometru (RA4) |
#int_TIMER0 //osetruje preteceni citace od anemometru (RA4) |
void TIMER0_isr(void) |
{ |
timer0_overflow_count++; |
93,7 → 93,7 |
printf("check\r\n\r\n"); |
} |
|
void InitTime(void) |
/*void InitTime(void) |
{ |
struct_tm t; |
|
117,14 → 117,14 |
|
printf("\r\n\n"); |
} |
*/ |
|
|
void main() |
{ |
|
char tString[32]; |
unsigned int32 t; |
time_t tTime = 0; |
// char tString[32]; |
// unsigned int32 t; |
// time_t tTime = 0; |
|
|
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
140,7 → 140,7 |
// setup_oscillator(OSC_8MHZ|OSC_INTRC); |
|
|
InitTime(); |
// InitTime(); |
|
/* Setup timer 2 |
* On a 4 Mhz clock, this will trigger a timer2 interrupt every 1.0 ms |
148,7 → 148,7 |
* OverflowTime = 4 * (1/OscFrequency) * Prescale * Period * Postscale |
* For 4 Mhz: .001 seconds = 4 * (1/4000000 seconds) * 4 * 250 * 1 |
*/ |
#if getenv("CLOCK")==4000000) |
/* #if getenv("CLOCK")==4000000) |
setup_timer_2(T2_DIV_BY_1,250,4); |
#elif getenv("CLOCK")==20000000) |
setup_timer_2(T2_DIV_BY_4,250,5); |
157,7 → 157,7 |
#endif |
|
/* Enable the timer 2 interrupt, or it will not fire */ |
enable_interrupts(INT_TIMER2); |
// enable_interrupts(INT_TIMER2); |
/* Enable interrupts globally too, otherwise no interrupt will fire */ |
|
|
187,22 → 187,7 |
|
while(true) |
{ |
|
set_timer1(0); |
delay_ms(999); |
delay_us(966); |
// count=get_timer1(); |
// Get the time |
tTime = time(NULL); |
// Get the string representation of the time */ |
|
ctime(&tTime, tString); |
|
|
/* Print the time to RS-232 */ |
printf("Time: %s\n\r", tString); |
|
printf("count: %Lu %X %X %X %X\r\n",count, buffer[0],buffer[1],buffer[2],buffer[3]); |
printf("count: %X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]); |
printf("%6.1f %u \n\r", anemo, rain); |
|
delay_ms(1000); |