you've got me -
the code is legit no malware
the code is available with current kit based speed alert devices but I need to modify it for a personal project. I just Downloaded MPLAB today and ran the first couple of instructions and found a list of errors. I was expecting everything to be in order:
Heres the code in full:
part 1:
- if need be i'll contact the developers website on why their code is ridden with bugs. Thanks for look at it.Code:; File SPEED254.ASM changes from SPEED.ASM to allow speed readings up to 254km/h ; Uses assembly code for PIC16F84 microcontroller ; This program is for a car speed alarm. It utilises three 7-segment displays ; which show the set speed. The speed setting can be altered with up and down pushbutton ; switches from 0 to 255km/h in 5km/h steps. When the speed of the vehicle reaches the set speed, ; the alarm sounds and an LED lights up. The alarm is a short beep beep sound while the LED ; remains lit until the speed is reduced below the alarm speed or the alarm speed is increased ; above the vehicles speed. ; ; A rotating magnet or magnets installed on the vehicles tail shaft or drive shaft ; trigger an inductive (coil) sensor to detect vehicle speed and this signal is detected via ; an interrupt in the processor. ; ; Calibration can be made by setting an alarm speed on the display and then bringing the ; vehicle speed up to the alarm speed as shown on the vehicles speedometer. ; The Calibrate switch is then pressed. The display will show CAL until ; calibrated. Display will show Err (error) if too few pulses or none are present while calibrating. ; No calibration allowed in speedometer mode. ; ; Each pressing the Mode switch will cycle between alarm speed indication, speedometer ; and off which disables the speed alarm. ; ; Alarm indication occurs for speedometer and alarm speed modes. ; ; Pressing the Up switch at power up will set the speed alarm for either a ; repeat warning of overspeed or single alarm. The repeat alarm will produce a tone every ; 10-seconds until the speed goes below the setting or the speed setting is increased above ; the speed. ; ; When pressing the Up switch at power up, a 'r' on the right display indicates repeat ; alarm and a '-' indicates no-repeat alarm option. ; ; Pressing the Mode switch at power up will toggle the speed alarm with the speedometer on or off ; If the display shows an 'S' then the speedometer function will operate and a '-' indicates that ; the speedometer is off. ; ; Pressing the Down switch at power up will set the speed alarm threshold point either high or ; low. The low threshold means that the alarm will sound at the set speed and switch off ; when the speed goes 1km/h or less below this speed. The high threshold will set the alarm ; when the speed is 1km/h or more above the set speed and go off for speeds at or below the ; set speed. A high setting will be indicated by an 'H' and a low setting by an 'L'as shown during ; power up with the down switch pressed. ; ; Processor pin allocations are as follows: ; RA0 Output disp1 driving transistor for common anode display ; RA1 Output disp2 ; RA2 Output disp3 ; RA3 Output for alarm ; RA4 Input from switches ; RB0 Input for wheel sensor (interrupt) ; RB1 c segment drive for seven segment LED display ; RB2 d segment drive ; RB3 e segment drive ; RB4 f segment drive ; RB5 a segment drive ; RB6 b segment drive ; RB7 g segment drive ; CPU configuration ; list P=16F84 #include "p16f84.inc" __config _XT_OSC & _WDT_OFF & _PWRTE_ON ; Define variables at memory locations ; EEPROM DATA EEPROM1 equ H'00' ; non-volatile storage for display1 EEPROM2 equ H'01' ; non-volatile storage for display2 EEPROM3 equ H'02' ; non-volatile storage for display3 EEPROM4 equ H'03' ; non-volatile storage to toggle repeat alarm feature and mode EEPROM5 equ H'04' ; non-volatile storage of LS byte of calibration number EEPROM6 equ H'05' ; non-volatile storage of MS byte of calibration number ; RAM DISP1 equ H'0C' ; working storage for Display1 value alarm speed mode DISP2 equ H'0D' ; working storage for Display2 value alarm speed mode DISP3 equ H'0E' ; working storage for Display3 value alarm speed mode STATUS_TMP equ H'0F' ; temp storage for status during interrupt W_TMP equ H'10' ; temporary storage for w during interrupt VALUE_1 equ H'11' ; delay value storage VALUE_2 equ H'12' ; delay value storage FLAG_1 equ H'13' ; flag, bit 0 = flag for closed switch, bit 1 for interrupt indicator ; bit 2 for alarm tone required, bit 3 for tone duty cycle, ; bit 4 alarm off, bit 5 overspeed, bit 6 EEPROM ; write repeat number, bit 7 for calibrate flag FLAG_2 equ H'14' ; alarm tone period settable from 00-FE FLAG_3 equ H'15' ; alarm tone sequence 00000000=on,00000001=off,00000010=on >=00000011 off, ; use a more significant bit to set reocurrence, bit 6 or 7 REPEAT equ H'16' ; bit 0 working store repeat alarm flag stored in EEPROM4, bit 1 on/off flag ; bit 1 on/off flag, bit 2 speedo/alarm select flag, bit 3 speedo on/off flag ; bit 4 alarm threshold SPEED_EQV equ H'17' ; storage for speed equivalent (value of 5 per 5km/h) 160km/h=160 TEMP_1 equ H'18' ; temporary working storage TEMP_2 equ H'19' ; temp storage TIME_CNT1 equ H'1A' ; counter for pulse count period TIME_CNT2 equ H'1B' ; counter for pulse count period TIME_CNT3 equ H'1C' ; working lsb calibration number stored in EEPROM5 TIME_CNT4 equ H'1D' ; working msd calibration number stored in EEPROM6 PULSE_CNT equ H'1E' ; counter for speed pulses compared with speed_eqv ERR_FLG equ H'1F' ; bit 0 is error flag for counter overrange during calibration SPEEDO equ H'20' ; latched value for speedometer obtained from PULSE_CNT SPEED1 equ H'21' ; display1 value during speedometer mode SPEED2 equ H'22' ; display2 value during speedometer mode SPEED3 equ H'23' ; display3 value during speedometer mode TEMP equ H'24' ; temporary register for BCD conversion BCD_0 equ H'25' ; decimal value MSD BCD_1 equ H'26' ; decimal packed BCD LS digits BIN_0 equ H'27' ; binary value for BCD conversion CNT_8 equ H'28' ; counter for BCD conversion TEMP_X equ H'29' ; temporary register for speed equivalent calculation ; preprogram EEPROM DATA ORG 2100 DE 0x00, 0x06, 0x00 ; preset EEPROM1-EEPROM3 ( initial speed setting is 60) DE 0x03 ; set EEPROM4 (repeat alarm on bit 0 and set to on/off bit 1) ; bit 2 speedo/set bit to set alarm mode, bit 3 speedo on ; bit 4 alarm threshold low DE 0xB3, 0x11 ; set calibration EEPROM5 & EEPROM6 (set to 100Hz = 160km/h ; calibration calculated out at 1.6s update time 160km/h = 160 pulses counted. ; 3.579545MHz/4/2/(256-100+2) = 353.1175us and require 4531Decimal for 1.6 sec or 11B3Hex ; Program begins ; define reset and interrupt vector start addresses org 0 ; start at address 0000h goto MAIN ; normal service routines from Reset vector org 4 ; interrupt vector 0004h, start interrupt routine here goto INTER ; go to start of interrupt routine, bypass subroutines ; subroutine to get seven segment display data. (This is placed at front of programm to prevent computed ; goto crossing 256 bit boundary. *PCL control only over least significant 8-bits*) SVNSEG andlw 0x0F; remove most significant bits if present prevents value >16h addwf PCL,f ; add value of display to program counter retlw B'10000000' ; 7-segment code 0 retlw B'10111100' ; 7-segment code 1 retlw B'00010010' ; 7-segment code 2 retlw B'00011000' ; 7-segment code 3 retlw B'00101100' ; 7-segment code 4 retlw B'01001000' ; 7-segment code 5 retlw B'01000000' ; 7-segment code 6 retlw B'10011100' ; 7-segment code 7 retlw B'00000000' ; 7-segment code 8 retlw B'00001000' ; 7-segment code 9 ;*******************************************************************************************




Bookmarks