o: ActiveSupport::Cache::Entry :@compressedF:@value"a?"[?
| main.c | ||
|---|---|---|
| 4 | 4 |
#include "main.h" |
| 5 | 5 |
#use i2c(SLAVE,Fast,sda=PIN_C4,scl=PIN_C3,force_hw,address=0xA2) // Motor 2 |
| 6 | 6 |
|
| 7 |
#include <time.h> //standard C time library |
|
| 8 |
#include <rtctimer.c> //library for time.h that uses timer2 as time base |
|
| 7 |
//#include <time.h> //standard C time library
|
|
| 8 |
//#include <rtctimer.c> //library for time.h that uses timer2 as time base
|
|
| 9 | 9 |
|
| 10 |
#include <stdlib.h> |
|
| 11 |
#include <input.c> //needed for the rs232 input routines |
|
| 10 |
//#include <stdlib.h>
|
|
| 11 |
//#include <input.c> //needed for the rs232 input routines
|
|
| 12 | 12 |
|
| 13 | 13 |
|
| 14 | 14 |
int16 count=0xA5A5; |
| ... | ... | |
| 70 | 70 |
output_toggle(PIN_E0); |
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 |
#int_TIMER0 //pro preteceni \u010d?ta\u010de p\u016flz\u016f od anemometru (RA4)
|
|
| 73 |
#int_TIMER0 //osetruje preteceni citace od anemometru (RA4)
|
|
| 74 | 74 |
void TIMER0_isr(void) |
| 75 | 75 |
{
|
| 76 | 76 |
timer0_overflow_count++; |
| ... | ... | |
| 93 | 93 |
printf("check\r\n\r\n");
|
| 94 | 94 |
} |
| 95 | 95 |
|
| 96 |
void InitTime(void) |
|
| 96 |
/*void InitTime(void)
|
|
| 97 | 97 |
{
|
| 98 | 98 |
struct_tm t; |
| 99 | 99 |
|
| ... | ... | |
| 117 | 117 |
|
| 118 | 118 |
printf("\r\n\n");
|
| 119 | 119 |
} |
| 120 |
*/ |
|
| 120 | 121 |
|
| 121 |
|
|
| 122 | 122 |
void main() |
| 123 | 123 |
{
|
| 124 | 124 |
|
| 125 |
char tString[32]; |
|
| 126 |
unsigned int32 t; |
|
| 127 |
time_t tTime = 0; |
|
| 125 |
// char tString[32];
|
|
| 126 |
// unsigned int32 t;
|
|
| 127 |
// time_t tTime = 0;
|
|
| 128 | 128 |
|
| 129 | 129 |
|
| 130 | 130 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
| ... | ... | |
| 140 | 140 |
// setup_oscillator(OSC_8MHZ|OSC_INTRC); |
| 141 | 141 |
|
| 142 | 142 |
|
| 143 |
InitTime(); |
|
| 143 |
// InitTime();
|
|
| 144 | 144 |
|
| 145 | 145 |
/* Setup timer 2 |
| 146 | 146 |
* On a 4 Mhz clock, this will trigger a timer2 interrupt every 1.0 ms |
| ... | ... | |
| 148 | 148 |
* OverflowTime = 4 * (1/OscFrequency) * Prescale * Period * Postscale |
| 149 | 149 |
* For 4 Mhz: .001 seconds = 4 * (1/4000000 seconds) * 4 * 250 * 1 |
| 150 | 150 |
*/ |
| 151 |
#if getenv("CLOCK")==4000000)
|
|
| 151 |
/* #if getenv("CLOCK")==4000000)
|
|
| 152 | 152 |
setup_timer_2(T2_DIV_BY_1,250,4); |
| 153 | 153 |
#elif getenv("CLOCK")==20000000)
|
| 154 | 154 |
setup_timer_2(T2_DIV_BY_4,250,5); |
| ... | ... | |
| 157 | 157 |
#endif |
| 158 | 158 |
|
| 159 | 159 |
/* Enable the timer 2 interrupt, or it will not fire */ |
| 160 |
enable_interrupts(INT_TIMER2); |
|
| 160 |
// enable_interrupts(INT_TIMER2);
|
|
| 161 | 161 |
/* Enable interrupts globally too, otherwise no interrupt will fire */ |
| 162 | 162 |
|
| 163 | 163 |
|
| ... | ... | |
| 186 | 186 |
set_timer1(0); |
| 187 | 187 |
|
| 188 | 188 |
while(true) |
| 189 |
{
|
|
| 190 |
|
|
| 191 |
set_timer1(0); |
|
| 192 |
delay_ms(999); |
|
| 193 |
delay_us(966); |
|
| 194 |
// count=get_timer1(); |
|
| 195 |
// Get the time |
|
| 196 |
tTime = time(NULL); |
|
| 197 |
// Get the string representation of the time */ |
|
| 198 |
|
|
| 199 |
ctime(&tTime, tString); |
|
| 200 |
|
|
| 201 |
|
|
| 202 |
/* Print the time to RS-232 */ |
|
| 203 |
printf("Time: %s\n\r", tString);
|
|
| 204 |
|
|
| 205 |
printf("count: %Lu %X %X %X %X\r\n",count, buffer[0],buffer[1],buffer[2],buffer[3]);
|
|
| 189 |
{
|
|
| 190 |
printf("count: %X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]);
|
|
| 206 | 191 |
printf("%6.1f %u \n\r", anemo, rain);
|
| 207 | 192 |
|
| 208 | 193 |
delay_ms(1000); |