No changes between revisions
/Modules/Sensors/MAG01A/SW/PIC16F887/HMC5883L.c
0,0 → 1,101
void set_mag (void) //uvodni nastaveni na kontinualni mereni, rozsah ± 8.1 Ga, frekvence mereni 15HZ
{
i2c_start(); //nastavení Configuration Register A
I2C_Write(MAG_ADDR_W);
I2C_Write(0x00);
I2C_Write(0x70);
i2c_stop();
Delay_ms(6);
i2c_start(); //nastavení Configuration Register B
I2C_Write(MAG_ADDR_W);
I2C_Write(0x01);
I2C_Write(MAG_ROZ810);
i2c_stop();
 
Delay_ms(6);
 
i2c_start(); //nastveni Mode Register
I2C_Write(MAG_ADDR_W);
I2C_Write(0x02);
I2C_Write(0x00);
i2c_stop();
Delay_ms(6);
}
 
void set_mag_roz (unsigned int8 h) //nastavy rozsah
{
 
//
i2c_start();
I2C_Write(MAG_ADDR_W);
I2C_Write(0x01);
I2C_Write(h);
i2c_stop();
 
Delay_ms(6);
 
}
 
 
byte mag_read(byte reg) //pro cteni reg
{
i2c_start();
I2C_Write(MAG_ADDR_W);
I2C_write(reg);
i2c_stop();
i2c_start();
I2C_Write(MAG_ADDR_R);
reg=i2c_read(0);
return reg;
}
 
 
signed int16 mag_vypocet(unsigned int8 h, unsigned int8 l) //prepocet na 16bit cislo
{
signed int16 x;
x = (((unsigned int16) h << 8) + l );
return x;
}
 
 
signed int16 mag_readX(void) //nacteni osy x
{
unsigned int8 h,l;
signed int16 x;
h=mag_read(0x03);
l=mag_read(0x04);
x=mag_vypocet(h,l);
return x;
}
 
 
signed int16 mag_readY(void) //nacteni osy x
{
unsigned int8 h,l;
signed int16 x;
h=mag_read(0x07);
l=mag_read(0x08);
x=mag_vypocet(h,l);
return x;
}
 
 
signed int16 mag_readZ(void) //nacteni osy x
{
unsigned int8 h,l;
signed int16 x;
h=mag_read(0x05);
l=mag_read(0x06);
x=mag_vypocet(h,l);
return x;
}
 
 
/Modules/Sensors/MAG01A/SW/PIC16F887/HMC5883L.h
0,0 → 1,17
#define MAG_ADDR_R 0x3D //addresa pro cteni
#define MAG_ADDR_W 0x3C
 
 
//Konstanty nastavujici rozsah
//pro void set_mag_roz (unsigned int8 h)
#define MAG_ROZ088 0x00
#define MAG_ROZ130 0x20
#define MAG_ROZ190 0x40
#define MAG_ROZ250 0x60
#define MAG_ROZ400 0x80
#define MAG_ROZ470 0xA0
#define MAG_ROZ560 0xC0
#define MAG_ROZ810 0xE0
 
 
#include "HMC5883L.c"
/Modules/Sensors/MAG01A/SW/PIC16F887/main.bak
0,0 → 1,42
//Magnetometr Jan Chroust 2013
//vypise hodnoty jednotlivych os
 
#include "main.h"
#include "HMC5883L.h"
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
 
printf("Magnetometr: \r\n",);
printf("(c)mlab JACHO 2013: \r\n",);
printf("Vysledky z jednotlivych os:\r\n",);
signed int16 X,Y,Z;
 
 
while(true)
{
printf("Vysledky z jednotlivych os:\r\n",);
X=mag_readX();
Y=mag_readY();
Z=mag_readZ();
printf("X: %Ld \r\n", X);
printf("Y %Ld \r\n", Y);
printf("Z: %Ld \r\n", Z);
Delay_ms(2000);
}
}
/Modules/Sensors/MAG01A/SW/PIC16F887/main.c
0,0 → 1,42
//Magnetometr Jan Chroust 2013
//vypise hodnoty jednotlivych os
 
#include "main.h"
 
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
 
#include "HMC5883L.h"
void main()
{
 
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
 
printf("Magnetometr: \r\n",);
printf("(c)mlab JACHO 2013: \r\n",);
printf("Vysledky z jednotlivych os:\r\n",);
signed int16 X,Y,Z;
 
 
while(true)
{
printf("Vysledky z jednotlivych os:\r\n",);
X=mag_readX();
Y=mag_readY();
Z=mag_readZ();
printf("X: %Ld \r\n", X);
printf("Y %Ld \r\n", Y);
printf("Z: %Ld \r\n", Z);
Delay_ms(2000);
}
}
/Modules/Sensors/MAG01A/SW/PIC16F887/main.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Modules/Sensors/MAG01A/SW/PIC16F887/main.err
0,0 → 1,2
Memory usage: ROM=10% RAM=2% - 6%
0 Errors, 0 Warnings.
/Modules/Sensors/MAG01A/SW/PIC16F887/main.esym
0,0 → 1,448
D G "__PCM__" 0 44 ""4.106""
D G "__DEVICE__" 0 44 "887"
D G "__DATE__" 0 44 ""16-4-13""
D G "__TIME__" 0 44 ""18:24:02"" "Magnetometr Jan Chroust 2013"
d G "PIN_A0" 2 20 "40"
d G "PIN_A1" 2 21 "41"
d G "PIN_A2" 2 22 "42"
d G "PIN_A3" 2 23 "43"
d G "PIN_A4" 2 24 "44"
d G "PIN_A5" 2 25 "45"
d G "PIN_A6" 2 26 "46"
d G "PIN_A7" 2 27 "47"
d G "PIN_B0" 2 29 "48"
d G "PIN_B1" 2 30 "49"
d G "PIN_B2" 2 31 "50"
d G "PIN_B3" 2 32 "51"
d G "PIN_B4" 2 33 "52"
d G "PIN_B5" 2 34 "53"
d G "PIN_B6" 2 35 "54"
d G "PIN_B7" 2 36 "55"
d G "PIN_C0" 2 38 "56"
d G "PIN_C1" 2 39 "57"
d G "PIN_C2" 2 40 "58"
d G "PIN_C3" 2 41 "59"
d G "PIN_C4" 2 42 "60"
d G "PIN_C5" 2 43 "61"
d G "PIN_C6" 2 44 "62"
d G "PIN_C7" 2 45 "63"
d G "PIN_D0" 2 47 "64"
d G "PIN_D1" 2 48 "65"
d G "PIN_D2" 2 49 "66"
d G "PIN_D3" 2 50 "67"
d G "PIN_D4" 2 51 "68"
d G "PIN_D5" 2 52 "69"
d G "PIN_D6" 2 53 "70"
d G "PIN_D7" 2 54 "71"
d G "PIN_E0" 2 56 "72"
d G "PIN_E1" 2 57 "73"
d G "PIN_E2" 2 58 "74"
d G "PIN_E3" 2 59 "75"
d G "FALSE" 2 62 "0"
d G "TRUE" 2 63 "1"
d G "BYTE" 2 65 "int8"
d G "BOOLEAN" 2 66 "int1"
d G "getc" 2 68 "getch"
d G "fgetc" 2 69 "getch"
d G "getchar" 2 70 "getch"
d G "putc" 2 71 "putchar"
d G "fputc" 2 72 "putchar"
d G "fgets" 2 73 "gets"
d G "fputs" 2 74 "puts"
d G "WDT_FROM_SLEEP" 2 79 "3"
d G "WDT_TIMEOUT" 2 80 "11"
d G "MCLR_FROM_SLEEP" 2 81 "19"
d G "MCLR_FROM_RUN" 2 82 "27"
d G "NORMAL_POWER_UP" 2 83 "25"
d G "BROWNOUT_RESTART" 2 84 "26"
d G "T0_INTERNAL" 2 91 "0"
d G "T0_EXT_L_TO_H" 2 92 "32"
d G "T0_EXT_H_TO_L" 2 93 "48"
d G "T0_DIV_1" 2 95 "8"
d G "T0_DIV_2" 2 96 "0"
d G "T0_DIV_4" 2 97 "1"
d G "T0_DIV_8" 2 98 "2"
d G "T0_DIV_16" 2 99 "3"
d G "T0_DIV_32" 2 100 "4"
d G "T0_DIV_64" 2 101 "5"
d G "T0_DIV_128" 2 102 "6"
d G "T0_DIV_256" 2 103 "7"
d G "T0_8_BIT" 2 106 "0"
d G "RTCC_INTERNAL" 2 108 "0" "The following are provided for compatibility"
d G "RTCC_EXT_L_TO_H" 2 109 "32" "with older compiler versions"
d G "RTCC_EXT_H_TO_L" 2 110 "48"
d G "RTCC_DIV_1" 2 111 "8"
d G "RTCC_DIV_2" 2 112 "0"
d G "RTCC_DIV_4" 2 113 "1"
d G "RTCC_DIV_8" 2 114 "2"
d G "RTCC_DIV_16" 2 115 "3"
d G "RTCC_DIV_32" 2 116 "4"
d G "RTCC_DIV_64" 2 117 "5"
d G "RTCC_DIV_128" 2 118 "6"
d G "RTCC_DIV_256" 2 119 "7"
d G "RTCC_8_BIT" 2 120 "0"
d G "WDT_18MS" 2 132 "8"
d G "WDT_36MS" 2 133 "9"
d G "WDT_72MS" 2 134 "10"
d G "WDT_144MS" 2 135 "11"
d G "WDT_288MS" 2 136 "12"
d G "WDT_576MS" 2 137 "13"
d G "WDT_1152MS" 2 138 "14"
d G "WDT_2304MS" 2 139 "15"
d G "WDT_ON" 2 143 "0x4100"
d G "WDT_OFF" 2 144 "0"
d G "WDT_DIV_16" 2 145 "0x100"
d G "WDT_DIV_8" 2 146 "0x300"
d G "WDT_DIV_4" 2 147 "0x500"
d G "WDT_DIV_2" 2 148 "0x700"
d G "WDT_TIMES_1" 2 149 "0x900" "Default"
d G "WDT_TIMES_2" 2 150 "0xB00"
d G "WDT_TIMES_4" 2 151 "0xD00"
d G "WDT_TIMES_8" 2 152 "0xF00"
d G "WDT_TIMES_16" 2 153 "0x1100"
d G "WDT_TIMES_32" 2 154 "0x1300"
d G "WDT_TIMES_64" 2 155 "0x1500"
d G "WDT_TIMES_128" 2 156 "0x1700"
d G "T1_DISABLED" 2 162 "0"
d G "T1_INTERNAL" 2 163 "5"
d G "T1_EXTERNAL" 2 164 "7"
d G "T1_EXTERNAL_SYNC" 2 165 "3"
d G "T1_CLK_OUT" 2 167 "8"
d G "T1_DIV_BY_1" 2 169 "0"
d G "T1_DIV_BY_2" 2 170 "0x10"
d G "T1_DIV_BY_4" 2 171 "0x20"
d G "T1_DIV_BY_8" 2 172 "0x30"
d G "T1_GATE" 2 174 "0x40"
d G "T1_GATE_INVERTED" 2 175 "0xC0"
d G "T2_DISABLED" 2 180 "0"
d G "T2_DIV_BY_1" 2 181 "4"
d G "T2_DIV_BY_4" 2 182 "5"
d G "T2_DIV_BY_16" 2 183 "6"
d G "CCP_OFF" 2 189 "0"
d G "CCP_CAPTURE_FE" 2 190 "4"
d G "CCP_CAPTURE_RE" 2 191 "5"
d G "CCP_CAPTURE_DIV_4" 2 192 "6"
d G "CCP_CAPTURE_DIV_16" 2 193 "7"
d G "CCP_COMPARE_SET_ON_MATCH" 2 194 "8"
d G "CCP_COMPARE_CLR_ON_MATCH" 2 195 "9"
d G "CCP_COMPARE_INT" 2 196 "0xA"
d G "CCP_COMPARE_RESET_TIMER" 2 197 "0xB"
d G "CCP_PWM" 2 198 "0xC"
d G "CCP_PWM_PLUS_1" 2 199 "0x1c"
d G "CCP_PWM_PLUS_2" 2 200 "0x2c"
d G "CCP_PWM_PLUS_3" 2 201 "0x3c"
d G "CCP_PWM_H_H" 2 206 "0x0c"
d G "CCP_PWM_H_L" 2 207 "0x0d"
d G "CCP_PWM_L_H" 2 208 "0x0e"
d G "CCP_PWM_L_L" 2 209 "0x0f"
d G "CCP_PWM_FULL_BRIDGE" 2 211 "0x40"
d G "CCP_PWM_FULL_BRIDGE_REV" 2 212 "0xC0"
d G "CCP_PWM_HALF_BRIDGE" 2 213 "0x80"
d G "CCP_SHUTDOWN_ON_COMP1" 2 215 "0x100000"
d G "CCP_SHUTDOWN_ON_COMP2" 2 216 "0x200000"
d G "CCP_SHUTDOWN_ON_COMP" 2 217 "0x300000"
d G "CCP_SHUTDOWN_ON_INT0" 2 218 "0x400000"
d G "CCP_SHUTDOWN_ON_COMP1_INT0" 2 219 "0x500000"
d G "CCP_SHUTDOWN_ON_COMP2_INT0" 2 220 "0x600000"
d G "CCP_SHUTDOWN_ON_COMP_INT0" 2 221 "0x700000"
d G "CCP_SHUTDOWN_AC_L" 2 223 "0x000000"
d G "CCP_SHUTDOWN_AC_H" 2 224 "0x040000"
d G "CCP_SHUTDOWN_AC_F" 2 225 "0x080000"
d G "CCP_SHUTDOWN_BD_L" 2 227 "0x000000"
d G "CCP_SHUTDOWN_BD_H" 2 228 "0x010000"
d G "CCP_SHUTDOWN_BD_F" 2 229 "0x020000"
d G "CCP_SHUTDOWN_RESTART" 2 231 "0x80000000"
d G "CCP_PULSE_STEERING_A" 2 233 "0x01000000"
d G "CCP_PULSE_STEERING_B" 2 234 "0x02000000"
d G "CCP_PULSE_STEERING_C" 2 235 "0x04000000"
d G "CCP_PULSE_STEERING_D" 2 236 "0x08000000"
d G "CCP_PULSE_STEERING_SYNC" 2 237 "0x10000000"
d G "SPI_MASTER" 2 245 "0x20"
d G "SPI_SLAVE" 2 246 "0x24"
d G "SPI_L_TO_H" 2 247 "0"
d G "SPI_H_TO_L" 2 248 "0x10"
d G "SPI_CLK_DIV_4" 2 249 "0"
d G "SPI_CLK_DIV_16" 2 250 "1"
d G "SPI_CLK_DIV_64" 2 251 "2"
d G "SPI_CLK_T2" 2 252 "3"
d G "SPI_SS_DISABLED" 2 253 "1"
d G "SPI_SAMPLE_AT_END" 2 255 "0x8000"
d G "SPI_XMIT_L_TO_H" 2 256 "0x4000"
d G "UART_ADDRESS" 2 262 "2"
d G "UART_DATA" 2 263 "4"
d G "UART_AUTODETECT" 2 264 "8"
d G "UART_AUTODETECT_NOWAIT" 2 265 "9"
d G "UART_WAKEUP_ON_RDA" 2 266 "10"
d G "UART_SEND_BREAK" 2 267 "13"
d G "NC_NC_NC_NC" 2 273 "0x00"
d G "NC_NC" 2 274 "0x00"
d G "CP1_A0_A3" 2 277 "0x00090080"
d G "CP1_A1_A3" 2 278 "0x000A0081"
d G "CP1_B3_A3" 2 279 "0x00880082"
d G "CP1_B1_A3" 2 280 "0x00280083"
d G "CP1_A0_VREF" 2 281 "0x00010084"
d G "CP1_A1_VREF" 2 282 "0x00020085"
d G "CP1_B3_VREF" 2 283 "0x00800086"
d G "CP1_B1_VREF" 2 284 "0x00200087"
d G "CP1_OUT_ON_A4" 2 286 "0x00000020"
d G "CP1_INVERT" 2 287 "0x00000010"
d G "CP1_ABSOLUTE_VREF" 2 288 "0x20000000"
d G "CP2_A0_A2" 2 291 "0x00058000"
d G "CP2_A1_A2" 2 292 "0x00068100"
d G "CP2_B3_A2" 2 293 "0x00848200"
d G "CP2_B1_A2" 2 294 "0x00248300"
d G "CP2_A0_VREF" 2 295 "0x00018400"
d G "CP2_A1_VREF" 2 296 "0x00028500"
d G "CP2_B3_VREF" 2 297 "0x00808600"
d G "CP2_B1_VREF" 2 298 "0x00208700"
d G "CP2_OUT_ON_A5" 2 300 "0x00002000"
d G "CP2_INVERT" 2 301 "0x00001000"
d G "CP2_ABSOLUTE_VREF" 2 302 "0x10000000"
d G "CP2_T1_SYNC" 2 305 "0x01000000"
d G "CP2_T1_GATE" 2 306 "0x02000000"
d G "VREF_LOW" 2 315 "0xa0"
d G "VREF_HIGH" 2 316 "0x80"
d G "OSC_31KHZ" 2 322 "1"
d G "OSC_125KHZ" 2 323 "0x11"
d G "OSC_250KHZ" 2 324 "0x21"
d G "OSC_500KHZ" 2 325 "0x31"
d G "OSC_1MHZ" 2 326 "0x41"
d G "OSC_2MHZ" 2 327 "0x51"
d G "OSC_4MHZ" 2 328 "0x61"
d G "OSC_8MHZ" 2 329 "0x71"
d G "OSC_INTRC" 2 330 "1"
d G "OSC_NORMAL" 2 331 "0"
d G "OSC_STATE_STABLE" 2 333 "4"
d G "OSC_31KHZ_STABLE" 2 334 "2"
d G "ADC_OFF" 2 342 "0" "ADC Off"
d G "ADC_CLOCK_DIV_2" 2 343 "0x100"
d G "ADC_CLOCK_DIV_8" 2 344 "0x40"
d G "ADC_CLOCK_DIV_32" 2 345 "0x80"
d G "ADC_CLOCK_INTERNAL" 2 346 "0xc0" "Internal 2-6us"
d G "sAN0" 2 350 "1" "| A0"
d G "sAN1" 2 351 "2" "| A1"
d G "sAN2" 2 352 "4" "| A2"
d G "sAN3" 2 353 "8" "| A3"
d G "sAN4" 2 354 "16" "| A5"
d G "sAN5" 2 355 "32" "| E0"
d G "sAN6" 2 356 "64" "| E1"
d G "sAN7" 2 357 "128" "| E2"
d G "sAN8" 2 358 "0x10000" "| B2"
d G "sAN9" 2 359 "0x20000" "| B3"
d G "sAN10" 2 360 "0x40000" "| B1"
d G "sAN11" 2 361 "0x80000" "| B4"
d G "sAN12" 2 362 "0x100000" "| B0"
d G "sAN13" 2 363 "0x200000" "| B5"
d G "NO_ANALOGS" 2 364 "0" "None"
d G "ALL_ANALOG" 2 365 "0x1F00FF" "A0 A1 A2 A3 A5 E0 E1 E2 B0 B1 B2 B3 B4 B5"
d G "VSS_VDD" 2 368 "0x0000" "| Range 0-Vdd"
d G "VSS_VREF" 2 369 "0x1000" "| Range 0-Vref"
d G "VREF_VREF" 2 370 "0x3000" "| Range Vref-Vref"
d G "VREF_VDD" 2 371 "0x2000" "| Range Vref-Vdd"
d G "ADC_START_AND_READ" 2 375 "7" "This is the default if nothing is specified"
d G "ADC_START_ONLY" 2 376 "1"
d G "ADC_READ_ONLY" 2 377 "6"
d G "L_TO_H" 2 389 "0x40"
d G "H_TO_L" 2 390 "0"
d G "GLOBAL" 2 392 "0x0BC0"
d G "INT_RTCC" 2 393 "0x000B20"
d G "INT_RB" 2 394 "0x01FF0B08"
d G "INT_EXT_L2H" 2 395 "0x50000B10"
d G "INT_EXT_H2L" 2 396 "0x60000B10"
d G "INT_EXT" 2 397 "0x000B10"
d G "INT_AD" 2 398 "0x008C40"
d G "INT_TBE" 2 399 "0x008C10"
d G "INT_RDA" 2 400 "0x008C20"
d G "INT_TIMER1" 2 401 "0x008C01"
d G "INT_TIMER2" 2 402 "0x008C02"
d G "INT_CCP1" 2 403 "0x008C04"
d G "INT_CCP2" 2 404 "0x008D01"
d G "INT_SSP" 2 405 "0x008C08"
d G "INT_BUSCOL" 2 406 "0x008D08"
d G "INT_EEPROM" 2 407 "0x008D10"
d G "INT_TIMER0" 2 408 "0x000B20"
d G "INT_OSC_FAIL" 2 409 "0x008D80"
d G "INT_COMP" 2 410 "0x008D20"
d G "INT_COMP2" 2 411 "0x008D40"
d G "INT_ULPWU" 2 412 "0x008D04"
d G "INT_RB0" 2 413 "0x0010B08"
d G "INT_RB1" 2 414 "0x0020B08"
d G "INT_RB2" 2 415 "0x0040B08"
d G "INT_RB3" 2 416 "0x0080B08"
d G "INT_RB4" 2 417 "0x0100B08"
d G "INT_RB5" 2 418 "0x0200B08"
d G "INT_RB6" 2 419 "0x0400B08"
d G "INT_RB7" 2 420 "0x0800B08"
D G "EEPROM_SDA" 0 6 "PIN_B0"
D G "EEPROM_SCL" 0 7 "PIN_B1"
D G "MAG_ADDR_R" 3 1 "0x3D" "addresa pro cteni"
D G "MAG_ADDR_W" 3 2 "0x3C"
D G "MAG_ROZ088" 3 7 "0x00"
D G "MAG_ROZ130" 3 8 "0x20"
D G "MAG_ROZ190" 3 9 "0x40"
D G "MAG_ROZ250" 3 10 "0x60"
D G "MAG_ROZ400" 3 11 "0x80"
D G "MAG_ROZ470" 3 12 "0xA0"
D G "MAG_ROZ560" 3 13 "0xC0"
D G "MAG_ROZ810" 3 14 "0xE0"
F G "set_mag" 4 1 "void()" "uvodni nastaveni na kontinualni mereni, rozsah ± 8.1 Ga, frekvence mereni 15HZ"
C L "set_mag" 4 3 1 "FUNCTION"
C L "set_mag" 4 3 1 "FUNCTION"
C L "set_mag" 4 3 1 "FUNCTION"
F G "set_mag_roz" 4 26 "void()"
V L "h" 4 26 "int8" "nastavy rozsah"
F G "mag_read" 4 44 "int8()"
V L "reg" 4 44 "int8" "pro cteni reg"
F G "mag_vypocet" 4 58 "sint16()"
V L "h" 4 58 "int8"
V L "l" 4 58 "int8" "prepocet na 16bit cislo"
V L "x" 4 60 "sint16"
F G "mag_readX" 4 66 "sint16()" "nacteni osy x"
V L "h" 4 68 "int8"
V L "l" 4 68 "int8"
V L "x" 4 69 "sint16"
F G "mag_readY" 4 78 "sint16(int8 )" "nacteni osy x"
V L "h" 4 80 "int8"
V L "l" 4 80 "int8"
V L "x" 4 81 "sint16"
F G "mag_readZ" 4 90 "sint16()" "nacteni osy x"
V L "h" 4 92 "int8"
V L "l" 4 92 "int8"
V L "x" 4 93 "sint16"
F G "MAIN" 0 12 "void()"
C L "MAIN" 0 22 1 "FUNCTION"
V L "x" 0 27 "sint16"
V L "Y" 0 27 "sint16"
V L "Z" 0 27 "sint16"
F B "reset_cpu" 0 0
F B "abs" 1 0
F B "sleep_ulpwu" 1 0
F B "sleep" 0 0
F B "delay_cycles" 1 0
F B "read_bank" 2 0
F B "write_bank" 3 0
F B "shift_left" 2 2
F B "shift_right" 2 2
F B "rotate_left" 2 0
F B "rotate_right" 2 0
F B "_mul" 2 0
F B "memset" 3 0
F B "isamoung" 2 0
F B "isamong" 2 0
F B "bit_set" 2 0
F B "bit_clear" 2 0
F B "bit_test" 2 0
F B "toupper" 1 0
F B "tolower" 1 0
F B "swap" 1 0
F B "printf" 1 255
F B "fprintf" 1 255
F B "sprintf" 1 255
F B "make8" 2 0
F B "make16" 2 0
F B "make32" 1 255
F B "label_address" 1 1
F B "goto_address" 1 0
F B "_va_arg" 1 0
F B "offsetofbit" 2 2
F B "enable_interrupts" 1 0
F B "disable_interrupts" 1 0
F B "interrupt_active" 1 0
F B "clear_interrupt" 1 0
F B "jump_to_isr" 1 0
F B "ext_int_edge" 1 2
F B "read_eeprom" 1 0
F B "write_eeprom" 2 0
F B "read_program_eeprom" 1 0
F B "write_program_eeprom" 2 0
F B "write_program_memory" 4 0
F B "write_program_memory8" 4 0
F B "read_program_memory" 4 0
F B "read_program_memory8" 4 0
F B "erase_program_eeprom" 1 0
F B "strcpy" 2 0
F B "memcpy" 3 0
F B "strstr100" 2 0
F B "output_high" 1 0
F B "output_low" 1 0
F B "input" 1 0
F B "input_state" 1 0
F B "output_float" 1 0
F B "output_drive" 1 0
F B "output_bit" 1 1
F B "output_toggle" 1 0
F B "output_a" 1 0
F B "output_b" 1 0
F B "output_c" 1 0
F B "output_d" 1 0
F B "output_e" 1 0
F B "input_a" 0 0
F B "input_b" 0 0
F B "input_c" 0 0
F B "input_d" 0 0
F B "input_e" 0 0
F B "set_tris_a" 1 0
F B "set_tris_b" 1 0
F B "set_tris_c" 1 0
F B "set_tris_d" 1 0
F B "set_tris_e" 1 0
F B "get_tris_a" 0 0
F B "get_tris_b" 0 0
F B "get_tris_c" 0 0
F B "get_tris_d" 0 0
F B "get_tris_e" 0 0
F B "input_change_a" 0 0
F B "input_change_b" 0 0
F B "input_change_c" 0 0
F B "input_change_d" 0 0
F B "input_change_e" 0 0
F B "port_b_pullups" 1 0
F B "setup_counters" 2 0
F B "setup_wdt" 1 0
F B "restart_cause" 0 0
F B "restart_wdt" 0 0
F B "get_rtcc" 0 0
F B "set_rtcc" 1 0
F B "get_timer0" 0 0
F B "set_timer0" 1 0
F B "setup_comparator" 1 0
F B "setup_port_a" 1 0
F B "setup_adc_ports" 1 0
F B "setup_adc" 1 0
F B "set_adc_channel" 1 0
F B "read_adc" 0 1
F B "adc_done" 0 0
F B "setup_timer_0" 1 0
F B "setup_vref" 1 0
F B "setup_timer_1" 1 0
F B "get_timer1" 0 0
F B "set_timer1" 1 0
F B "setup_timer_2" 3 0
F B "get_timer2" 0 0
F B "set_timer2" 1 0
F B "setup_ccp1" 1 2
F B "set_pwm1_duty" 1 0
F B "setup_ccp2" 1 0
F B "set_pwm2_duty" 1 0
F B "setup_oscillator" 1 2
F B "setup_spi" 1 0
F B "spi_read" 0 1
F B "spi_write" 1 0
F B "spi_data_is_in" 0 0
F B "setup_spi2" 1 0
F B "spi_read2" 0 1
F B "spi_write2" 1 0
F B "spi_data_is_in2" 0 0
F B "brownout_enable" 1 0
F B "delay_ms" 1 0
F B "delay_us" 1 0
F B "i2c_read" 0 2
F B "i2c_write" 1 2
F B "i2c_start" 0 2
F B "i2c_stop" 0 1
F B "i2c_isr_state" 0 1
F B "putchar" 1 2
F B "puts" 1 2
F B "getch" 0 1
F B "gets" 1 3
F B "kbhit" 0 1
/Modules/Sensors/MAG01A/SW/PIC16F887/main.h
0,0 → 1,19
#include <16F887.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOPUT //No Power Up Timer
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPD //No EE protection
#FUSES NOBROWNOUT //No brownout reset
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOWRT //Program memory not write protected
#FUSES BORV40 //Brownout reset at 4.0V
 
#use delay(clock=8000000)
 
/Modules/Sensors/MAG01A/SW/PIC16F887/main.hex
0,0 → 1,103
:1000000002308A00372A0000CD306737653AEF3674
:10001000653A721D20100D050000A831A936EC309C
:100020006210CA2043244F103218B1193A10A006AA
:100030000A00D63C73366532EB3C203D20356532F4
:10004000EE377436693BF9316810EF39BA060A00A9
:10005000D63C73366532EB3C203D20356532EE37B9
:100060007436693BF9316810EF39BA060A00831615
:100070008611831286110830F8003E280000F81718
:100080004F28F813B00C03188615031C8611781737
:100090004F287813F80B42284D28000086153F3072
:1000A0008400840B51280000F81B4128781B492844
:1000B0000800831603178C170C140000000083122D
:1000C0000C087F3903199D280313A70003170D0897
:1000D0000313A80003170F080313A9002708B00093
:1000E0003720280803178D000313290803178F00F2
:1000F00083168C170C140000000083120C0D0E0DDB
:100100007F3903199D280313A70003170D08031354
:10011000A80003170F080313A9002708B000372011
:10012000280803178D000313290803178F008D0A71
:1001300003198F0A03135928031703130800083003
:10014000F800000086108316861000008312AC0DA4
:100150000610031CAE288316061483120318B32856
:10016000831606108312831686148312861CB62803
:10017000F80BA128000086108316861000000614D4
:100180000000000086148312861CC428F8010000B9
:1001900006187814861083168610831206108316AC
:1001A000061083120800831606140000861400004F
:1001B0008312061083160610000083128610831621
:1001C00086103C308312AC009F202B08AC009F208F
:1001D00083160610000086148312861CED2800008A
:1001E000F12800008316061400000614000086148F
:1001F000000083120610831606100000831286107A
:10020000831686103D308312AC009F20F701083022
:10021000AD007708AE008316061400008614831222
:10022000861C102906180314061C0310F80D000084
:100230008316861083128610AD0B0B2983160614C5
:100240000000831206102E080319292983160610B0
:1002500083120000831686148312861C2D29000049
:10026000861083168610000083120610831606106F
:1002700078088312AB002B08F8000800B0012B08A7
:10028000AF00B000AF012C082F07F8003008FA00CB
:100290000318FA0A7808AD007A08AE002D08F800B5
:1002A0002E08F90008000330AB00D3207808A7001F
:1002B0000430AB00D3207808A8002708AB0028083A
:1002C000AC003E217908AA007808A9002908F800A6
:1002D0002A08F9008A110A12B52A0730AB00D32088
:1002E0007808A7000830AB00D3207808A8002708BA
:1002F000AB002808AC003E217908AA007808A900C4
:100300002908F8002A08F9008A110A12BA2A0530C9
:10031000AB00D3207808A7000630AB00D3207808C4
:10032000A8002708AB002808AC003E217908AA00E5
:100330007808A9002908F8002A08F9008A110A1289
:10034000BF2AAF010408AE002F10831B2F14A81F73
:10035000B129AE172E1EAE0AA709A809A70A0319CC
:10036000A80A280EF038AA00AA07E23EAB00323EE7
:10037000AD0028080F39AB07AB07AD07E93EAC006D
:10038000AC07AC07270E0F39AC07AD07AC0DAD0DB0
:10039000AD09AD0D27080F39AD07AA0D0730A9002B
:1003A0000A30AD07AC03031CD129AC07AB03031C17
:1003B000D529AB07AA03031CD929AA07A903031C43
:1003C000DD2929308400831307302E052E13840382
:1003D0002E05031DF2292E1A840A2E1AF229203026
:1003E000F7000F2A84072D30040203192E17000886
:1003F000F700031D032A2E1B032A2E1A1D2AAE19ED
:10040000032A20300E2AAE1F0B2A2D30F70084035A
:100410002E13AE130F2AAE152E123030F707A80197
:100420000408A7002810831B28147708B000372081
:1004300027088400831328188317840A2E1FF329A2
:10044000080028308400831300080319342A02307E
:10045000F800F701F70B2A2AF80B292A9730F70042
:10046000F70B302A800B272A8A110A12102B8401DD
:1004700083131F308305713083168F000F08861198
:1004800083128615831603170908C03989000313E0
:100490001F129F1200300317880083128701880102
:1004A0008901FF300313A000831603170908C03920
:1004B000890003131F129F12003003178800831254
:1004C00003131F139F1383169F1383121F14941279
:1004D000A012200883168700831220162008831696
:1004E00087008312A0112008831687000130831231
:1004F00094000030831694000108C7390838810041
:10050000831290010030F8009200003083169200B0
:100510008312201520088316870083129701831603
:100520009B019C0101309D00831203178701880104
:10053000890104308D0000308F00031359200D30E5
:1005400003178D0000308F00031359201930031753
:100550008D0000308F0003135920283003178D00C1
:1005600000308F000313592053297908A20078081E
:10057000A1006D297908A4007808A30087297908CB
:10058000A6007808A5005830B00037203A30B000F7
:1005900037202030B0003720103084002208A80017
:1005A0002108A700A1212030B00037200D30B00075
:1005B00037200A30B00037205930B00037202030C3
:1005C000B0003720103084002408A8002308A700BA
:1005D000A1212030B00037200D30B00037200A3084
:1005E000B00037205A30B00037203A30B000372002
:1005F0002030B0003720103084002608A8002508DD
:10060000A700A1212030B00037200D30B0003720E6
:100610000A30B00037200830A700FA30A800212A9D
:08062000A70B0D2BAD2A6300AE
:04400E00F52CFF3F4F
:00000001FF
;PIC16F887
;CRC=8247 CREATED="16-4-13 18:24"
/Modules/Sensors/MAG01A/SW/PIC16F887/main.lst
0,0 → 1,746
CCS PCM C Compiler, Version 4.106, 47914 16-4-13 18:24
 
Filename: c:\users\honza\documents\pic\i2c_magnetometr\main.lst
 
ROM used: 788 words (10%)
Largest free fragment is 2048
RAM used: 7 (2%) at main() level
22 (6%) worst case
Stack: 3 locations
 
*
0000: MOVLW 02
0001: MOVWF 0A
0002: GOTO 237
0003: NOP
.................... //Magnetometr Jan Chroust 2013
.................... //vypise hodnoty jednotlivych os
....................
.................... #include "main.h"
.................... #include <16F887.h>
.................... //////// Standard Header file for the PIC16F887 device ////////////////
.................... #device PIC16F887
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES INTRC //Internal RC Osc
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES IESO //Internal External Switch Over mode enabled
.................... #FUSES FCMEN //Fail-safe clock monitor enabled
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES BORV40 //Brownout reset at 4.0V
....................
.................... #use delay(clock=8000000)
*
0221: MOVLW 28
0222: MOVWF 04
0223: BCF 03.7
0224: MOVF 00,W
0225: BTFSC 03.2
0226: GOTO 234
0227: MOVLW 02
0228: MOVWF 78
0229: CLRF 77
022A: DECFSZ 77,F
022B: GOTO 22A
022C: DECFSZ 78,F
022D: GOTO 229
022E: MOVLW 97
022F: MOVWF 77
0230: DECFSZ 77,F
0231: GOTO 230
0232: DECFSZ 00,F
0233: GOTO 227
0234: BCF 0A.3
0235: BCF 0A.4
0236: GOTO 310 (RETURN)
....................
....................
....................
.................... #define EEPROM_SDA PIN_B0
.................... #define EEPROM_SCL PIN_B1
.................... #use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
*
009F: MOVLW 08
00A0: MOVWF 78
00A1: NOP
00A2: BCF 06.1
00A3: BSF 03.5
00A4: BCF 06.1
00A5: NOP
00A6: BCF 03.5
00A7: RLF 2C,F
00A8: BCF 06.0
00A9: BTFSS 03.0
00AA: GOTO 0AE
00AB: BSF 03.5
00AC: BSF 06.0
00AD: BCF 03.5
00AE: BTFSC 03.0
00AF: GOTO 0B3
00B0: BSF 03.5
00B1: BCF 06.0
00B2: BCF 03.5
00B3: BSF 03.5
00B4: BSF 06.1
00B5: BCF 03.5
00B6: BTFSS 06.1
00B7: GOTO 0B6
00B8: DECFSZ 78,F
00B9: GOTO 0A1
00BA: NOP
00BB: BCF 06.1
00BC: BSF 03.5
00BD: BCF 06.1
00BE: NOP
00BF: BSF 06.0
00C0: NOP
00C1: NOP
00C2: BSF 06.1
00C3: BCF 03.5
00C4: BTFSS 06.1
00C5: GOTO 0C4
00C6: CLRF 78
00C7: NOP
00C8: BTFSC 06.0
00C9: BSF 78.0
00CA: BCF 06.1
00CB: BSF 03.5
00CC: BCF 06.1
00CD: BCF 03.5
00CE: BCF 06.0
00CF: BSF 03.5
00D0: BCF 06.0
00D1: BCF 03.5
00D2: RETURN
*
0107: MOVLW 08
0108: MOVWF 2D
0109: MOVF 77,W
010A: MOVWF 2E
010B: BSF 03.5
010C: BSF 06.0
010D: NOP
010E: BSF 06.1
010F: BCF 03.5
0110: BTFSS 06.1
0111: GOTO 110
0112: BTFSC 06.0
0113: BSF 03.0
0114: BTFSS 06.0
0115: BCF 03.0
0116: RLF 78,F
0117: NOP
0118: BSF 03.5
0119: BCF 06.1
011A: BCF 03.5
011B: BCF 06.1
011C: DECFSZ 2D,F
011D: GOTO 10B
011E: BSF 03.5
011F: BSF 06.0
0120: NOP
0121: BCF 03.5
0122: BCF 06.0
0123: MOVF 2E,W
0124: BTFSC 03.2
0125: GOTO 129
0126: BSF 03.5
0127: BCF 06.0
0128: BCF 03.5
0129: NOP
012A: BSF 03.5
012B: BSF 06.1
012C: BCF 03.5
012D: BTFSS 06.1
012E: GOTO 12D
012F: NOP
0130: BCF 06.1
0131: BSF 03.5
0132: BCF 06.1
0133: NOP
0134: BCF 03.5
0135: BCF 06.0
0136: BSF 03.5
0137: BCF 06.0
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
*
0037: BSF 03.5
0038: BCF 06.3
0039: BCF 03.5
003A: BCF 06.3
003B: MOVLW 08
003C: MOVWF 78
003D: GOTO 03E
003E: NOP
003F: BSF 78.7
0040: GOTO 04F
0041: BCF 78.7
0042: RRF 30,F
0043: BTFSC 03.0
0044: BSF 06.3
0045: BTFSS 03.0
0046: BCF 06.3
0047: BSF 78.6
0048: GOTO 04F
0049: BCF 78.6
004A: DECFSZ 78,F
004B: GOTO 042
004C: GOTO 04D
004D: NOP
004E: BSF 06.3
004F: MOVLW 3F
0050: MOVWF 04
0051: DECFSZ 04,F
0052: GOTO 051
0053: NOP
0054: BTFSC 78.7
0055: GOTO 041
0056: BTFSC 78.6
0057: GOTO 049
0058: RETURN
....................
.................... #include "HMC5883L.h"
.................... #define MAG_ADDR_R 0x3D //addresa pro cteni
.................... #define MAG_ADDR_W 0x3C
....................
....................
.................... //Konstanty nastavujici rozsah
.................... //pro void set_mag_roz (unsigned int8 h)
.................... #define MAG_ROZ088 0x00
.................... #define MAG_ROZ130 0x20
.................... #define MAG_ROZ190 0x40
.................... #define MAG_ROZ250 0x60
.................... #define MAG_ROZ400 0x80
.................... #define MAG_ROZ470 0xA0
.................... #define MAG_ROZ560 0xC0
.................... #define MAG_ROZ810 0xE0
....................
....................
.................... #include "HMC5883L.c"
.................... void set_mag (void) //uvodni nastaveni na kontinualni mereni, rozsah ± 8.1 Ga, frekvence mereni 15HZ
.................... {
.................... i2c_start(); //nastavení Configuration Register A
.................... I2C_Write(MAG_ADDR_W);
.................... I2C_Write(0x00);
.................... I2C_Write(0x70);
.................... i2c_stop();
.................... Delay_ms(6);
....................
.................... i2c_start(); //nastavení Configuration Register B
.................... I2C_Write(MAG_ADDR_W);
.................... I2C_Write(0x01);
.................... I2C_Write(MAG_ROZ810);
.................... i2c_stop();
....................
.................... Delay_ms(6);
....................
.................... i2c_start(); //nastveni Mode Register
.................... I2C_Write(MAG_ADDR_W);
.................... I2C_Write(0x02);
.................... I2C_Write(0x00);
.................... i2c_stop();
.................... Delay_ms(6);
.................... }
....................
.................... void set_mag_roz (unsigned int8 h) //nastavy rozsah
.................... {
....................
.................... //
....................
....................
.................... i2c_start();
.................... I2C_Write(MAG_ADDR_W);
.................... I2C_Write(0x01);
.................... I2C_Write(h);
.................... i2c_stop();
....................
.................... Delay_ms(6);
....................
....................
.................... }
....................
....................
.................... byte mag_read(byte reg) //pro cteni reg
.................... {
....................
.................... i2c_start();
*
00D3: BSF 03.5
00D4: BSF 06.0
00D5: NOP
00D6: BSF 06.1
00D7: NOP
00D8: BCF 03.5
00D9: BCF 06.0
00DA: BSF 03.5
00DB: BCF 06.0
00DC: NOP
00DD: BCF 03.5
00DE: BCF 06.1
00DF: BSF 03.5
00E0: BCF 06.1
.................... I2C_Write(MAG_ADDR_W);
00E1: MOVLW 3C
00E2: BCF 03.5
00E3: MOVWF 2C
00E4: CALL 09F
.................... I2C_write(reg);
00E5: MOVF 2B,W
00E6: MOVWF 2C
00E7: CALL 09F
.................... i2c_stop();
00E8: BSF 03.5
00E9: BCF 06.0
00EA: NOP
00EB: BSF 06.1
00EC: BCF 03.5
00ED: BTFSS 06.1
00EE: GOTO 0ED
00EF: NOP
00F0: GOTO 0F1
00F1: NOP
00F2: BSF 03.5
00F3: BSF 06.0
00F4: NOP
.................... i2c_start();
00F5: BSF 06.0
00F6: NOP
00F7: BSF 06.1
00F8: NOP
00F9: BCF 03.5
00FA: BCF 06.0
00FB: BSF 03.5
00FC: BCF 06.0
00FD: NOP
00FE: BCF 03.5
00FF: BCF 06.1
0100: BSF 03.5
0101: BCF 06.1
.................... I2C_Write(MAG_ADDR_R);
0102: MOVLW 3D
0103: BCF 03.5
0104: MOVWF 2C
0105: CALL 09F
.................... reg=i2c_read(0);
0106: CLRF 77
*
0138: MOVF 78,W
0139: BCF 03.5
013A: MOVWF 2B
.................... return reg;
013B: MOVF 2B,W
013C: MOVWF 78
.................... }
013D: RETURN
....................
....................
.................... signed int16 mag_vypocet(unsigned int8 h, unsigned int8 l) //prepocet na 16bit cislo
.................... {
.................... signed int16 x;
.................... x = (((unsigned int16) h << 8) + l );
013E: CLRF 30
013F: MOVF 2B,W
0140: MOVWF 2F
0141: MOVWF 30
0142: CLRF 2F
0143: MOVF 2C,W
0144: ADDWF 2F,W
0145: MOVWF 78
0146: MOVF 30,W
0147: MOVWF 7A
0148: BTFSC 03.0
0149: INCF 7A,F
014A: MOVF 78,W
014B: MOVWF 2D
014C: MOVF 7A,W
014D: MOVWF 2E
.................... return x;
014E: MOVF 2D,W
014F: MOVWF 78
0150: MOVF 2E,W
0151: MOVWF 79
.................... }
0152: RETURN
....................
....................
.................... signed int16 mag_readX(void) //nacteni osy x
.................... {
.................... unsigned int8 h,l;
.................... signed int16 x;
.................... h=mag_read(0x03);
0153: MOVLW 03
0154: MOVWF 2B
0155: CALL 0D3
0156: MOVF 78,W
0157: MOVWF 27
.................... l=mag_read(0x04);
0158: MOVLW 04
0159: MOVWF 2B
015A: CALL 0D3
015B: MOVF 78,W
015C: MOVWF 28
.................... x=mag_vypocet(h,l);
015D: MOVF 27,W
015E: MOVWF 2B
015F: MOVF 28,W
0160: MOVWF 2C
0161: CALL 13E
0162: MOVF 79,W
0163: MOVWF 2A
0164: MOVF 78,W
0165: MOVWF 29
.................... return x;
0166: MOVF 29,W
0167: MOVWF 78
0168: MOVF 2A,W
0169: MOVWF 79
....................
.................... }
016A: BCF 0A.3
016B: BCF 0A.4
016C: GOTO 2B5 (RETURN)
....................
....................
.................... signed int16 mag_readY(void) //nacteni osy x
.................... {
.................... unsigned int8 h,l;
.................... signed int16 x;
.................... h=mag_read(0x07);
016D: MOVLW 07
016E: MOVWF 2B
016F: CALL 0D3
0170: MOVF 78,W
0171: MOVWF 27
.................... l=mag_read(0x08);
0172: MOVLW 08
0173: MOVWF 2B
0174: CALL 0D3
0175: MOVF 78,W
0176: MOVWF 28
.................... x=mag_vypocet(h,l);
0177: MOVF 27,W
0178: MOVWF 2B
0179: MOVF 28,W
017A: MOVWF 2C
017B: CALL 13E
017C: MOVF 79,W
017D: MOVWF 2A
017E: MOVF 78,W
017F: MOVWF 29
.................... return x;
0180: MOVF 29,W
0181: MOVWF 78
0182: MOVF 2A,W
0183: MOVWF 79
....................
.................... }
0184: BCF 0A.3
0185: BCF 0A.4
0186: GOTO 2BA (RETURN)
....................
....................
.................... signed int16 mag_readZ(void) //nacteni osy x
.................... {
.................... unsigned int8 h,l;
.................... signed int16 x;
.................... h=mag_read(0x05);
0187: MOVLW 05
0188: MOVWF 2B
0189: CALL 0D3
018A: MOVF 78,W
018B: MOVWF 27
.................... l=mag_read(0x06);
018C: MOVLW 06
018D: MOVWF 2B
018E: CALL 0D3
018F: MOVF 78,W
0190: MOVWF 28
.................... x=mag_vypocet(h,l);
0191: MOVF 27,W
0192: MOVWF 2B
0193: MOVF 28,W
0194: MOVWF 2C
0195: CALL 13E
0196: MOVF 79,W
0197: MOVWF 2A
0198: MOVF 78,W
0199: MOVWF 29
.................... return x;
019A: MOVF 29,W
019B: MOVWF 78
019C: MOVF 2A,W
019D: MOVWF 79
....................
.................... }
019E: BCF 0A.3
019F: BCF 0A.4
01A0: GOTO 2BF (RETURN)
....................
....................
....................
....................
....................
.................... void main()
.................... {
*
0237: CLRF 04
0238: BCF 03.7
0239: MOVLW 1F
023A: ANDWF 03,F
023B: MOVLW 71
023C: BSF 03.5
023D: MOVWF 0F
023E: MOVF 0F,W
023F: BCF 06.3
0240: BCF 03.5
0241: BSF 06.3
0242: BSF 03.5
0243: BSF 03.6
0244: MOVF 09,W
0245: ANDLW C0
0246: MOVWF 09
0247: BCF 03.6
0248: BCF 1F.4
0249: BCF 1F.5
024A: MOVLW 00
024B: BSF 03.6
024C: MOVWF 08
024D: BCF 03.5
024E: CLRF 07
024F: CLRF 08
0250: CLRF 09
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
*
0254: BSF 03.5
0255: BSF 03.6
0256: MOVF 09,W
0257: ANDLW C0
0258: MOVWF 09
0259: BCF 03.6
025A: BCF 1F.4
025B: BCF 1F.5
025C: MOVLW 00
025D: BSF 03.6
025E: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_2);
025F: BCF 03.5
0260: BCF 03.6
0261: BCF 1F.6
0262: BCF 1F.7
0263: BSF 03.5
0264: BCF 1F.7
0265: BCF 03.5
0266: BSF 1F.0
.................... setup_spi(SPI_SS_DISABLED);
0267: BCF 14.5
0268: BCF 20.5
0269: MOVF 20,W
026A: BSF 03.5
026B: MOVWF 07
026C: BCF 03.5
026D: BSF 20.4
026E: MOVF 20,W
026F: BSF 03.5
0270: MOVWF 07
0271: BCF 03.5
0272: BCF 20.3
0273: MOVF 20,W
0274: BSF 03.5
0275: MOVWF 07
0276: MOVLW 01
0277: BCF 03.5
0278: MOVWF 14
0279: MOVLW 00
027A: BSF 03.5
027B: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
027C: MOVF 01,W
027D: ANDLW C7
027E: IORLW 08
027F: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0280: BCF 03.5
0281: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0282: MOVLW 00
0283: MOVWF 78
0284: MOVWF 12
0285: MOVLW 00
0286: BSF 03.5
0287: MOVWF 12
.................... setup_ccp1(CCP_OFF);
0288: BCF 03.5
0289: BSF 20.2
028A: MOVF 20,W
028B: BSF 03.5
028C: MOVWF 07
028D: BCF 03.5
028E: CLRF 17
028F: BSF 03.5
0290: CLRF 1B
0291: CLRF 1C
0292: MOVLW 01
0293: MOVWF 1D
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
0294: BCF 03.5
0295: BSF 03.6
0296: CLRF 07
0297: CLRF 08
0298: CLRF 09
....................
.................... printf("Magnetometr: \r\n",);
0299: MOVLW 04
029A: MOVWF 0D
029B: MOVLW 00
029C: MOVWF 0F
029D: BCF 03.6
029E: CALL 059
.................... printf("(c)mlab JACHO 2013: \r\n",);
029F: MOVLW 0D
02A0: BSF 03.6
02A1: MOVWF 0D
02A2: MOVLW 00
02A3: MOVWF 0F
02A4: BCF 03.6
02A5: CALL 059
.................... printf("Vysledky z jednotlivych os:\r\n",);
02A6: MOVLW 19
02A7: BSF 03.6
02A8: MOVWF 0D
02A9: MOVLW 00
02AA: MOVWF 0F
02AB: BCF 03.6
02AC: CALL 059
.................... signed int16 X,Y,Z;
....................
....................
.................... while(true)
.................... {
.................... printf("Vysledky z jednotlivych os:\r\n",);
02AD: MOVLW 28
02AE: BSF 03.6
02AF: MOVWF 0D
02B0: MOVLW 00
02B1: MOVWF 0F
02B2: BCF 03.6
02B3: CALL 059
.................... X=mag_readX();
02B4: GOTO 153
02B5: MOVF 79,W
02B6: MOVWF 22
02B7: MOVF 78,W
02B8: MOVWF 21
.................... Y=mag_readY();
02B9: GOTO 16D
02BA: MOVF 79,W
02BB: MOVWF 24
02BC: MOVF 78,W
02BD: MOVWF 23
.................... Z=mag_readZ();
02BE: GOTO 187
02BF: MOVF 79,W
02C0: MOVWF 26
02C1: MOVF 78,W
02C2: MOVWF 25
.................... printf("X: %Ld \r\n", X);
02C3: MOVLW 58
02C4: MOVWF 30
02C5: CALL 037
02C6: MOVLW 3A
02C7: MOVWF 30
02C8: CALL 037
02C9: MOVLW 20
02CA: MOVWF 30
02CB: CALL 037
02CC: MOVLW 10
02CD: MOVWF 04
02CE: MOVF 22,W
02CF: MOVWF 28
02D0: MOVF 21,W
02D1: MOVWF 27
02D2: CALL 1A1
02D3: MOVLW 20
02D4: MOVWF 30
02D5: CALL 037
02D6: MOVLW 0D
02D7: MOVWF 30
02D8: CALL 037
02D9: MOVLW 0A
02DA: MOVWF 30
02DB: CALL 037
.................... printf("Y %Ld \r\n", Y);
02DC: MOVLW 59
02DD: MOVWF 30
02DE: CALL 037
02DF: MOVLW 20
02E0: MOVWF 30
02E1: CALL 037
02E2: MOVLW 10
02E3: MOVWF 04
02E4: MOVF 24,W
02E5: MOVWF 28
02E6: MOVF 23,W
02E7: MOVWF 27
02E8: CALL 1A1
02E9: MOVLW 20
02EA: MOVWF 30
02EB: CALL 037
02EC: MOVLW 0D
02ED: MOVWF 30
02EE: CALL 037
02EF: MOVLW 0A
02F0: MOVWF 30
02F1: CALL 037
.................... printf("Z: %Ld \r\n", Z);
02F2: MOVLW 5A
02F3: MOVWF 30
02F4: CALL 037
02F5: MOVLW 3A
02F6: MOVWF 30
02F7: CALL 037
02F8: MOVLW 20
02F9: MOVWF 30
02FA: CALL 037
02FB: MOVLW 10
02FC: MOVWF 04
02FD: MOVF 26,W
02FE: MOVWF 28
02FF: MOVF 25,W
0300: MOVWF 27
0301: CALL 1A1
0302: MOVLW 20
0303: MOVWF 30
0304: CALL 037
0305: MOVLW 0D
0306: MOVWF 30
0307: CALL 037
0308: MOVLW 0A
0309: MOVWF 30
030A: CALL 037
.................... Delay_ms(2000);
030B: MOVLW 08
030C: MOVWF 27
030D: MOVLW FA
030E: MOVWF 28
030F: GOTO 221
0310: DECFSZ 27,F
0311: GOTO 30D
....................
.................... }
0312: GOTO 2AD
.................... }
0313: SLEEP
 
Configuration Fuses:
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
Word 2: 3FFF NOWRT BORV40
/Modules/Sensors/MAG01A/SW/PIC16F887/main.pjt
0,0 → 1,26
[PROJECT]
Target=C:\Users\Honza\Documents\pic\I2C_magnetometr\main.hex
Development_Mode=
Processor_Text=PIC16F887
ToolSuite=CCS
Processor=0x887F
[C:\Users\Honza\Documents\pic\I2C_magnetometr\main]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
[mru-list]
1=C:\Users\Honza\Documents\pic\I2C_magnetometr\main.c
[Windows]
0=0000 %S 0 0 796 451 3 0
[Units]
Link=0
Count=1
1=C:\Users\Honza\Documents\pic\I2C_magnetometr\main
[Opened Files]
1=..\I2C_magnetometr\main.c
2=..\kompas\main.c
3=HMC5883L.c
4=
/Modules/Sensors/MAG01A/SW/PIC16F887/main.sta
0,0 → 1,63
 
ROM used: 788 (10%)
788 (10%) including unused fragments
 
1 Average locations per line
12 Average locations per statement
 
RAM used: 7 (2%) at main() level
22 (6%) worst case
 
Stack used: 3 worst case (out of 8 total available)
 
Lines Stmts % Files
----- ----- --- -----
43 22 32 main.c
20 0 0 main.h
423 0 0 ..\..\..\..\..\Program Files (x86)\PICC\devices\16F887.h
19 0 0 HMC5883L.h
102 46 68 HMC5883L.c
----- -----
607 68 Total
 
Page ROM % RAM Vol Diff Functions:
---- --- --- --- --- ---- ----------
0 22 3 1 @delay_ms1
Inline 3 357 1.4 @I2C_READ_1
0 52 7 1 113 1.3 @I2C_WRITE_1
0 34 4 1 152 2.2 @PUTCHAR_1_
0 107 14 1 152 2.2 mag_read
0 21 3 6 129 4.6 mag_vypocet
0 26 3 4 171 2.7 mag_readX
0 26 3 4 171 2.7 mag_readY
0 26 3 4 171 2.7 mag_readZ
0 221 28 1 658 3.3 MAIN
0 9 1 0 44 1.9 @const99
0 70 9 3 257 7.2 @PSTRINGC7_68
0 12 2 0 @const101
0 15 2 0 1071 8.0 @const102
0 15 2 0 @const106
0 128 16 9 @PRINTF_LD_68
 
Program metrics:
Functions 12
Statements 68
Comments 109
Volume (V) 5531
Difficilty (D) 39.8
Effort to implement (E) 220066
Time to implement (T) 3 hours, 24 minutes
Est Delivered Bugs (B) 1
Cyclomatic Complexity 3
Maintainability (MI) 61
 
Segment Used Free
----------- ---- ----
00000-00003 4 0
00004-007FF 784 1260
00800-00FFF 0 2048
01000-017FF 0 2048
01800-01FFF 0 2048
 
 
 
/Modules/Sensors/MAG01A/SW/PIC16F887/main.sym
0,0 → 1,110
004-005 @READ_PROGRAM_MEMORY8.P1
004 @WRITE_PROGRAM_MEMORY8.P2
015 CCP_1_LOW
015 CCP_1
016 CCP_1_HIGH
01B CCP_2
01B CCP_2_LOW
01C CCP_2_HIGH
020 @TRIS_C
021-022 MAIN.x
023-024 MAIN.Y
025-026 MAIN.Z
027-028 @PRINTF_LD_68.P1
027 mag_readZ.h
027 mag_readX.h
027 mag_readY.h
027 MAIN.@SCRATCH1
027 @PSTRINGC7_68.@SCRATCH1
028 mag_readX.l
028 @delay_ms1.P1
028 mag_readY.l
028 mag_readZ.l
028 @PSTRINGC7_68.@SCRATCH2
029-02A mag_readY.x
029-02A mag_readX.x
029-02A mag_readZ.x
029 @PSTRINGC7_68.@SCRATCH3
029 @PRINTF_LD_68.@SCRATCH1
02A @PRINTF_LD_68.@SCRATCH2
02B mag_read.reg
02B mag_vypocet.h
02B @PRINTF_LD_68.@SCRATCH3
02C mag_vypocet.l
02C @I2C_WRITE_1.P1
02C @I2C_READ_1.P2
02C @PRINTF_LD_68.@SCRATCH4
02D-02E mag_vypocet.x
02D @I2C_READ_1.@SCRATCH1
02D @PRINTF_LD_68.@SCRATCH5
02E @I2C_READ_1.@SCRATCH2
02E @PRINTF_LD_68.@SCRATCH6
02F mag_vypocet.@SCRATCH1
02F @PRINTF_LD_68.@SCRATCH7
030 @PUTCHAR_1_.P1
030 mag_vypocet.@SCRATCH2
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
107.6 C1OUT
108.6 C2OUT
10D-10E @READ_PROGRAM_MEMORY8.P1
10D-10E @WRITE_PROGRAM_MEMORY8.P2
 
ROM Allocation:
0221 @delay_ms1
0107 @I2C_READ_1
009F @I2C_WRITE_1
0037 @PUTCHAR_1_
00D3 mag_read
013E mag_vypocet
0153 mag_readX
016D mag_readY
0187 mag_readZ
0237 MAIN
0004 @const99
0059 @PSTRINGC7_68
000D @const101
0019 @const102
0028 @const106
01A1 @PRINTF_LD_68
0237 @cinit
 
 
User Memory space:
 
User Memory space:
 
Project Directory:
c:\users\honza\documents\pic\i2c_magnetometr\
 
Project Files:
main.c
main.h
..\..\..\..\..\Program Files (x86)\PICC\devices\16F887.h
HMC5883L.h
HMC5883L.c
 
Units:
c:\users\honza\documents\pic\i2c_magnetometr\main (main)
 
Compiler Settings:
Processor: PIC16F887
Pointer Size: 16
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: UNSIGNED: 1,8,16
Float,Double: 32,32
 
Output Files:
Errors: main.err
Ext Symbols: main.esym
INHX8: main.hex
Symbols: main.sym
List: main.lst
Debug/COFF: main.cof
Project: main.PJT
Call Tree: main.tre
Statistics: main.sta
/Modules/Sensors/MAG01A/SW/PIC16F887/main.tre
0,0 → 1,75
ÀÄmain
ÀÄMAIN 0/221 Ram=1
ÃÄ??0??
ÃÄ@PSTRINGC7_68 0/70 Ram=3
³ ÃÄ@PUTCHAR_1_ 0/34 Ram=1
³ ÀÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PSTRINGC7_68 0/70 Ram=3
³ ÃÄ@PUTCHAR_1_ 0/34 Ram=1
³ ÀÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PSTRINGC7_68 0/70 Ram=3
³ ÃÄ@PUTCHAR_1_ 0/34 Ram=1
³ ÀÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PSTRINGC7_68 0/70 Ram=3
³ ÃÄ@PUTCHAR_1_ 0/34 Ram=1
³ ÀÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄmag_readX 0/26 Ram=4
³ ÃÄmag_read 0/107 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÀÄ@I2C_READ_1 (Inline) Ram=3
³ ÃÄmag_read 0/107 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÀÄ@I2C_READ_1 (Inline) Ram=3
³ ÀÄmag_vypocet 0/21 Ram=6
ÃÄmag_readY 0/26 Ram=4
³ ÃÄmag_read 0/107 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÀÄ@I2C_READ_1 (Inline) Ram=3
³ ÃÄmag_read 0/107 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÀÄ@I2C_READ_1 (Inline) Ram=3
³ ÀÄmag_vypocet 0/21 Ram=6
ÃÄmag_readZ 0/26 Ram=4
³ ÃÄmag_read 0/107 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÀÄ@I2C_READ_1 (Inline) Ram=3
³ ÃÄmag_read 0/107 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÃÄ@I2C_WRITE_1 0/52 Ram=1
³ ³ ÀÄ@I2C_READ_1 (Inline) Ram=3
³ ÀÄmag_vypocet 0/21 Ram=6
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PRINTF_LD_68 0/128 Ram=9
³ ÀÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PRINTF_LD_68 0/128 Ram=9
³ ÀÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PRINTF_LD_68 0/128 Ram=9
³ ÀÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÃÄ@PUTCHAR_1_ 0/34 Ram=1
ÀÄ@delay_ms1 0/22 Ram=1