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