ateyah
Newbie level 5
Hi all;
I work on My graduated project, so I need a help
I want to read data from ADC when I press on a button.
so that I wrote a code to active the INT when RB5=1,
but the INT does not answer,i used microbasic compiler.
this is the code:
*********************************
program abbad
dim sound as word[14]
dim a as byte
dim i as byte
sub procedure interrupt
if TestBit(INTCON,INTF) = 1 then
sound[a] = ADC_read(2)
if a=14 then
a=0
else
a=a+1
end if
clearbit (intcon,intf)
end if
end sub
main:
INTCON=%10010000
ADCON1 = $80 ' configure analog inputs and Vref
TRISA = $FF ' designate PORTA as input
TRISB.0 = 1 ' designate RB7, RB6 pins as outputs
TRISD = $00 ' designate PORTD as output
TRISC = $00
a=0
while true
sound[a] = ADC_read(2)
for i =0 to 14
if sound[a]=sound then
portd=$FF
end if
next i
wend
end.
**************
thanks
I work on My graduated project, so I need a help
I want to read data from ADC when I press on a button.
so that I wrote a code to active the INT when RB5=1,
but the INT does not answer,i used microbasic compiler.
this is the code:
*********************************
program abbad
dim sound as word[14]
dim a as byte
dim i as byte
sub procedure interrupt
if TestBit(INTCON,INTF) = 1 then
sound[a] = ADC_read(2)
if a=14 then
a=0
else
a=a+1
end if
clearbit (intcon,intf)
end if
end sub
main:
INTCON=%10010000
ADCON1 = $80 ' configure analog inputs and Vref
TRISA = $FF ' designate PORTA as input
TRISB.0 = 1 ' designate RB7, RB6 pins as outputs
TRISD = $00 ' designate PORTD as output
TRISC = $00
a=0
while true
sound[a] = ADC_read(2)
for i =0 to 14
if sound[a]=sound then
portd=$FF
end if
next i
wend
end.
**************
thanks