<root>
<file schema='101' />
<macros >
<macro >
<flowline name='ChipTemp' description='Experimental internal temperature macro.
Reads internal temperature.' >
<return name='Return' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
<param name='getTemp' type='b1' description='0=no, 1= yes' isconst='0' isinit='0' usrinit='0' setinit='' />
<param name='convSpeed' type='u8' description='see text inside macro' isconst='0' isinit='0' usrinit='0' setinit='' />
<param name='TempOnOff' type='b1' description='0=off 1=on' isconst='0' isinit='0' usrinit='0' setinit='' />
<param name='chargeTime' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
<command class_type='comment' title='' comment='This is untested code intended only for code experimentation.
Use at your own risk.' textarea='12,0,12,0' cmdcolor='14609663' cmdcolor_sec='14609663' />
<command class_type='comment' title='' comment='This macro converts the voltage output of the temperature unit into a number
(the return value) using the ADC module. A temperature increase will result in an
increase in the return value number.
There needs to be a delay between turning the unit on(TempOnOff=1) and 
reading the temperature(getTemp=1). See data sheet for more info. 

TempOnOff: turns the temperature unit on if set, off if clear.
getTemp: will return the relative temperature(return value) if set, or zero if clear.
ConvSpeed: selects the ADC conversion clock speed, use the following format
           0b00000000(0x00)(0)  = fosc/2
           0b01000000(0x40)(64) = fosc/4
           0b00010000(0x10)(16) = fosc/8
           0b01010000(0x50)(80) = fosc/16
           0b00100000(0x20)(32) = fosc/32
           0b01100000(0x60)(96) = fosc/64
           0b01110000(0x70)(112)= FRC
(See the data sheet for more info on ADC conversion clock speed to select.)
chargeTime: selects the time to charge the ADC cap before the conversion begins.' textarea='12,0,12,0' cmdcolor='14609663' cmdcolor_sec='14609663' />
<command class_type='decision' title='Decision' cmdcolor='255' cmdcolor_sec='11494655' exp='.TempOnOff = 1' swap='0' >
<flowline >
<command class_type='native' title='turn on temp unit' ccode='FVRCON=(FVRCON | 0b00110000);' cmdcolor='3389439' cmdcolor_sec='3389439' language='C' />
<command class_type='decision' title='Decision' cmdcolor='255' cmdcolor_sec='11494655' exp='.getTemp = 1' swap='0' >
<flowline >
<command class_type='native' title='C Code' ccode='ADCON1=FCL_CONVSPEED;
set_bit(ADCON1,ADFM);
ADCON0=0b01110101;
while(FCL_CHARGETIME&gt;0)FCL_CHARGETIME--;//charge adc capacitor
set_bit(ADCON0,GO_nDONE);//start adc conversion
while (ADCON0 &amp; 0x02);//wait till conversion is complete
ADCON0=0x00;//turn off adc module
FCR_RETVAL = ADRESL | ( ADRESH &lt;&lt; 8 );' cmdcolor='3389439' cmdcolor_sec='3389439' language='C' />
</flowline>
<flowline >
<command class_type='native' title='C Code' ccode='FCR_RETVAL = 0;' cmdcolor='3389439' cmdcolor_sec='3389439' language='C' />
</flowline>
</command>
</flowline>
<flowline >
<command class_type='native' title='turn off temperature unit' ccode='FVRCON= (FVRCON &amp; 0b11001111);
FCR_RETVAL = 0;' cmdcolor='3389439' cmdcolor_sec='3389439' language='C' />
</flowline>
</command>
</flowline>
</macro>
</macros>
<variables />
</root>
