mramos1
Active Member
OK. I spent $300 on junk compilers over the last 3 weeks, and this afternoon said I need to do it in ASM. I downloaded MPLAB, installed it. Wrote the code, that I know will need lots of work (but include it if someone wants to assemble it in their ASM, it will have errors as I can not get past the processor type).. I can not quickbuild it. I did not try their WINASM, I went in the editor, typed my code, do a quick build and error with the processor, which is listed in their pulldown.
I am using the 12f509.. I did not see a .INC file for any 509 chip in Program Files\MPLAbs either.
Do I need to find an older MPLAB program to write this code, or download a .INC for it?
Or anyone have an assembler they like. I wanted to use MPLAB for the debugger, but not locked into it. Here is the code, nasty, but just tring to get it to make a .HEX file, I will clean it up from there.. Also I had the variables as EQU starting at open RAM, but the MPLAB seemed to like that format. Main objective is to get it to make .hex.
I am using the 12f509.. I did not see a .INC file for any 509 chip in Program Files\MPLAbs either.
Do I need to find an older MPLAB program to write this code, or download a .INC for it?
Or anyone have an assembler they like. I wanted to use MPLAB for the debugger, but not locked into it. Here is the code, nasty, but just tring to get it to make a .HEX file, I will clean it up from there.. Also I had the variables as EQU starting at open RAM, but the MPLAB seemed to like that format. Main objective is to get it to make .hex.
Code:
list p=12f509
#include p12f509.inc
CONFIG WDT=ON, WDTPS=256
CONFIG OSCS=ON, OSC=XT
BUZZ equ portB.1 ;piezo buzzer pin
LDR equ portB.0 ;LDR/cap pin
variables udata
count res 1 ;how many highs when cap is discharging
dcount res 1 ;delay counter
lcount res 1 ;loop counter to read LDR
org 0
goto top
code
top
movlw b'00000000' ;set buzzer and LDR as output
tris portb
bcf LDR ;ground out LDR/cap
call delay ;let cap charge
movlw b'00000001' ;flip LDR for input
tris portb
clrf count ;zero counters, count = number of highs from RC, lcount is passes to check
clrf lcount
loop
btfsc LDR ;if bit is high
incf count ; increment count
decfsz lcount,f ;decrement loop counter
goto loop ;if loop counter <> 0 loop
btfsc count,7 ;test bit 7 if more than 128 highs
goto buzz ;if true go buzz
nap
sleep ;else sleep wait for WDT
goto top
buzz
clrf lcount
noise
bsf buzz ;set piezo high
call delay ;pause
bcf buzz ;clr piezo
call delay ;pause
decfsc lcount ;if lcount is <> 0
gotot noise ;then more noise
goto nap ;else to nap
end
;
;
;
delay clrf dcount
delay1
decfsz dcount,f
goto delay1
return
Last edited: