/Modules/TDC/GP201A/SW/PICinterface/GP2.c |
---|
1,72 → 1,110 |
void TDC_init() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0x70); |
output_high(TDC_ENABLE); |
} |
void TDC_reset() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0x50); |
output_high(TDC_ENABLE); |
} |
void TDC_start_cycle() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0x01); |
output_high(TDC_ENABLE); |
} |
void TDC_start_temp() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0x02); |
output_high(TDC_ENABLE); |
} |
void TDC_start_cal_resonator() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0x03); |
output_high(TDC_ENABLE); |
} |
void TDC_start_cal() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0x04); |
output_high(TDC_ENABLE); |
} |
unsigned int32 TDC_get_measurement(int num) |
{ |
unsigned int32 ret; |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0xB0 + num - 1); |
return spi_xfer(TDC_stream,0,32); |
ret=spi_xfer(TDC_stream,0,32); |
output_high(TDC_ENABLE); |
return ret; |
} |
unsigned int16 TDC_get_status() |
{ |
spi_xfer(TDC_stream,0xB4); |
return spi_xfer(TDC_stream,0,16); |
unsigned int16 ret; |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0xB4,8); |
ret=spi_xfer(TDC_stream,0,16); |
output_high(TDC_ENABLE); |
return ret; |
} |
unsigned int8 TDC_get_reg1() |
{ |
spi_xfer(TDC_stream,0xB5); |
return spi_xfer(TDC_stream,0,8); |
unsigned int8 ret; |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0xB5,8); |
ret=spi_xfer(TDC_stream,0,8); |
output_high(TDC_ENABLE); |
return ret; |
} |
void TDC_setup_reg1() |
{ |
spi_xfer(TDC_stream,0xB0); |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0x81,8); |
spi_xfer(TDC_stream,0x224000,24); |
output_high(TDC_ENABLE); |
} |
void TDC_setup_reg2() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0xB1); |
output_high(TDC_ENABLE); |
} |
void TDC_setup_reg3() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0xB2); |
output_high(TDC_ENABLE); |
} |
void TDC_setup_reg4() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0xB3); |
output_high(TDC_ENABLE); |
} |
void TDC_setup_reg5() |
{ |
output_low(TDC_ENABLE); |
spi_xfer(TDC_stream,0xB4); |
output_high(TDC_ENABLE); |
} |
/Modules/TDC/GP201A/SW/PICinterface/GP2.h |
---|
1,0 → 0,0 |
#include "GP2.c" |
#define TDC_HITIN1_0 0x0 << 8 |
#define TDC_HITIN1_1 0x1 << 8 |
#define TDC_HITIN1_2 0x2 << 8 |
#define TDC_HITIN1_3 0x3 << 8 |
#define TDC_HITIN1_4 0x4 << 8 |
#define TDC_HITIN2_0 0x0 << 11 |
#define TDC_HITIN2_1 0x1 << 11 |
#define TDC_HITIN2_2 0x2 << 11 |
#define TDC_HITIN2_3 0x3 << 11 |
#define TDC_HITIN2_4 0x4 << 11 |
#define TDC_FAST_INIT_EN 0x1 << 15 |
#define TDC_FAST_INIT_DIS 0x0 << 15 |
#define TDC_HIT1_ |
/Modules/TDC/GP201A/SW/PICinterface/main.c |
---|
16,12 → 16,14 |
setup_comparator(NC_NC_NC_NC); |
setup_vref(FALSE); |
//TDC_reset(); |
TDC_reset(); |
//TDC_init(); |
TDC_setup_reg1(); |
while(true) |
{ |
delay_ms(500); |
printf("ret: %LX \n", TDC_get_reg1()); |
// printf("ret: %LX \n", TDC_get_measurement(1)); |
}; |
} |
/Modules/TDC/GP201A/SW/PICinterface/main.h |
---|
33,7 → 33,9 |
#use delay(clock=20000000) |
#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B6,bits=8) |
#use spi(DI=PIN_B1, DO=PIN_B0, CLK=PIN_B2, ENABLE=PIN_B3, stream=TDC_stream) // uses software SPI |
#define TDC_ENABLE PIN_B3 //enable pin for SPI communication |
#use spi(DI=PIN_B1, DO=PIN_B0, CLK=PIN_B2, stream=TDC_stream, bits=32) // uses software SPI |
/Modules/TDC/GP201A/SW/PICinterface/main.hex |
---|
1,38 → 1,43 |
:10000000A7EF00F07265743A20254C58200A0000D2 |
:10001000EA6A060EE96EEF500DE0060E016E006A08 |
:10002000002EFED7012EFBD77B0E006E002EFED7D2 |
:10003000EF2EF3D7E8EF00F00950200807E00A6E32 |
:1000400005360636073608360A2EFAD7938293907D |
:1000500093948A9493968A9609C00AF08A8408AE8B |
:100060008A9008BE8A8005360636073608368A9496 |
:10007000003601360236033681A2009081B200803C |
:100080000A2EECD78A86000C086A076A066AB50E43 |
:10009000056E200E096ED0DF086A076A066A056AD7 |
:1000A000080E096EC9DF00C001F0EBEF00F0939E6F |
:1000B0008A9E080E016E00D00000018E0ED0019EB7 |
:1000C0000932D8B08A8ED8A08A9E018C06D0019CB5 |
:1000D000012EF6D700D000008A8EA70EE96EE92E19 |
:1000E000FED700D001BEEBD701BCF1D7000C090050 |
:1000F000F6CF07F0F7CF08F0F5CF09F0D8DF07C04B |
:10010000F6FF08C0F7FF062EF2D7F4EF00F007BEA7 |
:100110000FD00F0E006E063800160A0E005C03E2C8 |
:10012000300E002602D00750002600C009F0BFDFC5 |
:100130000F0E06160A0E065C02E2300E02D0079E73 |
:100140000750062606C009F0B2DFF9EF00F0F86AA2 |
:10015000D09EEA6AE96A939E8A8E938293909394E2 |
:100160008A9493968A96C150C00B0F09C16E070EF0 |
:10017000B46EC150C00B0F09C16EC090C092C09444 |
:10018000C09EC2809698C69A949E93809392010EC8 |
:10019000C66E000EC76ED190800ED56ECD6A000E71 |
:1001A000CA6E000ECB6E9484BD6AB76AB66A070E3B |
:1001B000B46E9250926E100E006E002EFED70000AC |
:1001C000B450A19CB56A020E056EFA0E066E20D7D9 |
:1001D000052EFBD759D701C005F0040EF66E000EB0 |
:1001E000F76E050E066E83D705C006F0370E076E54 |
:1001F0008ED7200E096E5BDF0A0E096E58DFE3D73B |
:020200000300F9 |
:10000000D0EF00F07265743A20254C58200A0000A9 |
:100010000A50200807E00B6E063607360836093608 |
:100020000B2EFAD79382939093948A940AC00BF084 |
:100030008A8409AE8A9009BE8A8006360736083659 |
:1000400009368A94003601360236033681A20090C2 |
:1000500081B200800B2EECD7000C93968A96096A29 |
:10006000086A076A500E066E200E0A6ED1DF93965C |
:100070008A860BEF01F093968A96096A086A076AE6 |
:10008000810E066E080E0A6EC3DF096A220E086E24 |
:10009000400E076E066A180E0A6EBADF93968A86BD |
:1000A0000CEF01F0EA6A060EE96EEF500DE0060E65 |
:1000B000016E006A002EFED7012EFBD77B0E006E6C |
:1000C000002EFED7EF2EF3D711EF01F093968A960C |
:1000D000096A086A076AB50E066E080E0A6E98DF8E |
:1000E000096A086A076A066A080E0A6E91DF0150FB |
:1000F00000C005F093968A8605C001F014EF01F068 |
:10010000939E8A9E080E016E00D00000018E0ED0D4 |
:10011000019E0932D8B08A8ED8A08A9E018C06D062 |
:10012000019C012EF6D700D000008A8EA70EE96E42 |
:10013000E92EFED700D001BEEBD701BCF1D7000CF1 |
:100140000900F6CF07F0F7CF08F0F5CF09F0D8DFB8 |
:1001500007C0F6FF08C0F7FF062EF2D71DEF01F02B |
:1001600007BE0FD00F0E006E063800160A0E005C98 |
:1001700003E2300E002602D00750002600C009F02E |
:10018000BFDF0F0E06160A0E065C02E2300E02D02A |
:10019000079E0750062606C009F0B2DF22EF01F0E5 |
:1001A000F86AD09EEA6AE96A939E8A8E9382939057 |
:1001B00093948A94C150C00B0F09C16E070EB46EA0 |
:1001C000C150C00B0F09C16EC090C092C094C09EB8 |
:1001D000C2809698C69A949E93809392010EC66EA2 |
:1001E000000EC76ED190800ED56ECD6A000ECA6E1D |
:1001F000000ECB6E9484BD6AB76AB66A070EB46E01 |
:100200009250926E100E006E002EFED70000B45079 |
:10021000A19CB56A22D72FD7020E056EFA0E066E84 |
:1002200041D7052EFBD752D701C005F0040EF66E5C |
:10023000000EF76E050E066E83D705C006F0370E6A |
:10024000076E8ED7200E096E5BDF0A0E096E58DF2F |
:04025000E3D70300ED |
:020000040030CA |
:0E00000027CC390E0087A1000FC00FE00F4083 |
:00000001FF |
;PIC18F4550 |
;CRC=5083 CREATED="27-12-10 01:06" |
;CRC=1441 CREATED="27-12-10 17:22" |
/Modules/TDC/GP201A/SW/PICinterface/main.pjt |
---|
20,7 → 20,7 |
Count=1 |
1=C:\Users\kakl\Documents\MLAB\Modules\TDC\GP201A\SW\PICinterface\main |
[Opened Files] |
1=main.c |
1=..\..\..\..\TDC\GP201A\SW\PICinterface\main.c |
2=main.h |
3=..\..\..\..\..\..\..\..\..\Program Files\PICC\Devices\18F4550.h |
4=GP2.c |