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