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 #include "HMC5883L.h" 2 #include "HMC5883L.h"
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   3  
12 void main() 4 void main()
13 { 5 {
14   -  
15 setup_adc_ports(NO_ANALOGS|VSS_VDD); 6 setup_adc_ports(NO_ANALOGS|VSS_VDD);
16 setup_adc(ADC_CLOCK_DIV_2); 7 setup_adc(ADC_CLOCK_DIV_2);
17 setup_spi(SPI_SS_DISABLED); 8 setup_spi(SPI_SS_DISABLED);
18 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 9 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
19 setup_timer_1(T1_DISABLED); 10 setup_timer_1(T1_DISABLED);
20 setup_timer_2(T2_DISABLED,0,1); 11 setup_timer_2(T2_DISABLED,0,1);
21 setup_ccp1(CCP_OFF); 12 setup_ccp1(CCP_OFF);
22 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard 13 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
23   14  
24 printf("Magnetometr: \r\n",); 15 printf("Magnetometr: \r\n",);
25 printf("(c)mlab JACHO 2013: \r\n",); 16 printf("(c)mlab JACHO 2013: \r\n",);
26 printf("Vysledky z jednotlivych os:\r\n",); 17 printf("Vysledky z jednotlivych os:\r\n",);
27 signed int16 X,Y,Z; 18 signed int16 X,Y,Z;
28   -  
29   19  
30 while(true) 20 while(true)
31 { 21 {
32 printf("Vysledky z jednotlivych os:\r\n",); 22 printf("Vysledky z jednotlivych os:\r\n",);
33 X=mag_readX(); 23 X = mag_readX();
34 Y=mag_readY(); 24 Y = mag_readY();
35 Z=mag_readZ(); 25 Z = mag_readZ();
36 printf("X: %Ld \r\n", X); 26 printf("X: %Ld \r\n", X);
37 printf("Y %Ld \r\n", Y); 27 printf("Y %Ld \r\n", Y);
38 printf("Z: %Ld \r\n", Z); 28 printf("Z: %Ld \r\n", Z);
39 Delay_ms(2000); 29 Delay_ms(500);
40 30
41 } 31 }
42 } 32 }