OTP单片机实现电位计控制PWM程序芯片解密
单片机源程序如下:
- 芯片解密#include <12F509.h>
- 芯片解密#fuses INTRC,NOWDT,NOPROTECT, NOMCLR
- 芯片解密#use delay(clock=4000000)
- #define GP0 PIN_B0
- #define GP1 PIN_B1
- #define GP2 PIN_B2
- #define GP3 PIN_B3
- #define GP4 PIN_B4
- #define GP5 PIN_B5
- #define set_options(value) {#ASM \
- MOVLW value \
- OPTION \
- #ENDASM}
- #define UART_TX_HI() output_high(GP2)
- #define UART_TX_LO() output_low(GP2)
- #define BitTime 40
- void GP5_In()
- {
- output_low (GP5);
- set_tris_b(0xfa);
- }
- void GP5_Out()
- {
- set_tris_b(0xda);
- output_high (GP5);
- }
- unsigned char duty;
- unsigned char i;
- void cycle_backward (void)
- {
- output_low (GP2);
- delay_us (70);
- output_high (GP2);
- delay_us (70);
- }
- void Get_Pos()
- {
- set_tris_b(0xfa); //GP5 input
- while(input(GP5) == 0)
- {
- duty++;
- }
- set_tris_b(0xda); //GP5 output
- }
- void GetAdc()
- {
- duty = 0;
- output_high(GP4); //Activate Pullup
-
- while(input(GP5) == 0)
- {
- duty++;
- if(duty==255)
- {
- output_low(GP4);
- return;
- }
- }
- output_low(GP4); // No pullup
- }
- void UART_Transmit(unsigned char DataValue)
- {
-
- /* Basic Logic
-
- TX pin is usually high. A high to low bit is the starting bit and
- a low to high bit is the ending bit. No parity bit. No flow control.
- BitCount is the number of bits to transmit. Data is transmitted LSB first.
- */
- // Send Start Bit
- UART_TX_LO();
- delay_us(BitTime); //delay_us(33); //
- for ( i = 0; i < 8; i++ )
- {
- // Set Data pin according to the DataValue
- if( ((DataValue>>i)&0x1) == 0x1 ) // If Bit is high
- {
- UART_TX_HI();
- }
- else // If Bit is low
- {
- UART_TX_LO();
- }
- delay_us(BitTime); //delay_us(33); //
- }
- // Send Stop Bit
- UART_TX_HI();
- delay_us(BitTime); //delay_us(33); //
- }
上一篇:AI辅助编程芯片解密

芯片解密