1045 |
jacho |
1 |
//Magnetometr Jan Chroust 2013 |
|
|
2 |
//vypise hodnoty jednotlivych os |
|
|
3 |
|
|
|
4 |
|
|
|
5 |
//pro prvotni nastaveni restartovat procesor |
|
|
6 |
|
|
|
7 |
#include "main.h" |
|
|
8 |
|
|
|
9 |
#define EEPROM_SDA PIN_C4 |
|
|
10 |
#define EEPROM_SCL PIN_C3 |
|
|
11 |
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL) |
|
|
12 |
#use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD |
|
|
13 |
|
|
|
14 |
#include "HMC5883L.h" |
|
|
15 |
void main() |
|
|
16 |
{ |
|
|
17 |
|
|
|
18 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
19 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
20 |
setup_spi(SPI_SS_DISABLED); |
|
|
21 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
22 |
setup_timer_1(T1_DISABLED); |
|
|
23 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
24 |
setup_ccp1(CCP_OFF); |
|
|
25 |
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
|
|
26 |
|
|
|
27 |
printf("Magnetometr: \r\n",); |
|
|
28 |
printf("(c)mlab JACHO 2013: \r\n",); |
|
|
29 |
printf("Vysledky z jednotlivych os:\r\n",); |
|
|
30 |
signed int16 X,Y,Z; |
|
|
31 |
|
|
|
32 |
set_mag (); |
|
|
33 |
while(true) |
|
|
34 |
{ |
|
|
35 |
printf("Vysledky z jednotlivych os:\r\n",); |
|
|
36 |
X=mag_readX(); |
|
|
37 |
Y=mag_readY(); |
|
|
38 |
Z=mag_readZ(); |
|
|
39 |
printf("X: %Ld \r\n", X); |
|
|
40 |
printf("Y %Ld \r\n", Y); |
|
|
41 |
printf("Z: %Ld \r\n", Z); |
|
|
42 |
Delay_ms(2000); |
|
|
43 |
|
|
|
44 |
} |
|
|
45 |
} |