DOH, just notice we are in the PBC section. You have to use POKE and PEEK with the according RAM address.
something like
POKE $86,0 ' set PORTB as output
POKE $06,255 ' set all PORTB pins to 1
try this and post your results...
DOH, just notice we are in the PBC section. You have to use POKE and PEEK with the according RAM address.
something like
POKE $86,0 ' set PORTB as output
POKE $06,255 ' set all PORTB pins to 1
try this and post your results...
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Here's what I'm trying to accomplish: I have a loop set-up where the only time the program can come out of the loop is when Port A bit 0 OR RA0 goes low. It then makes other pins go high and/or low to make a certain number out of a seven segment dieplay. What I thought is that I could just make the PIC do this on the fly where when RA0 goes low the program will instantly come out of the loop and continue on with the code. What you're describing is that when the pin goes low you would have to store that informaiton into ram and then retrive the data so that the PIC can compare the two results, as in the IF...Than statement. I"m assuming that you're correct since you're all over this forum! I'm just trying to learn how to do certain things rather than being told how to do it, and not learning anything! I really appreicate you helping me out.
IN PBP we will write something like this...
IN PBC, IMO it will look something like.. please correct me someone if i'm wrongCode:TRISB=0 ' set PORTB as output TRISA=%11111101 ' set PORTA as input except PORTA.1 a VAR BYTE a=1 Loop: Toggle PORTA.1 IF PORTA.0=0 then Gosub DoSomething ' testing PORTA.0 status goto Loop DoSomething: PORTB=a ' send to PORTB if a<255 then a=a+1 else a=1 endif return
this will toggle the PORTA.1 pin untill PORTA.0 go low, once it go to low, it will send the value of b0 var to PORTB.... well it's suppose toCode:POKE $86,0 ' set PORTB as output POKE $85,253 ' set PORTA.1 as output other as input b0=0 loop: toggle 0 PEEK $05,b1 ' read PORTA status b1=b1 & 1 ' keep only bit 0 of PORTA ' well i don't know if you can use something like ' if b1.0=0 then gosub DoSomething... worth to give a try if b1=0 then gosub DoSomething goto loop DoSomething: POKE $06,b0 ' send to PORTB if b0<255 then b0=b0+1 else b0=1 endif return![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I guess I just don't understand the principals of the IF..Then statement. IN the manual there are some examples for the statement, but when I tried to mimic the example it didn't work.
The example is:
If Pin0 = 0 Then pushd
now does Pin0 need to be equated to something? IN the beginning of the code do I need something like this?
Pin0 VAR PortA.0?
or
Pin0 = PortA.0?
when I type in PortA.0, the compiler gives me an illegal character error because of the period but I do not know how to otherwise specify any pin of either portA or PortB (RA0,RA1.....RB0, RB1.....)
I really appreciate all your help, the problem is that I don't have much programming knowledge, and when I try to understand your replies it goes over my head.
well unfortunately you don't have PicBasic PRO where everything is so much simple.
your example IF PORTA.0= will work in PBP.
Can you try this and post your results
Code:' alias definition ' ================ ' Symbol PORTA = 5 Symbol TRISA = $85 Symbol PORTB = 6 Symbol TRISB = $86 ' I/O setting ' ========== ' POKE TRISA=255 ' set input to all PORTA pins POKE TRISB=0 ' set output to all PORTB pins ' Main Loop ' ========= ' START: PEEK PORTA,B0 ' read the whole PORTA and place result into B0 IF B0.0=1 THEN ' read bit 0 of B0 wich is the PORTA status ' ' If PORTA.0 is 1 then place all PORTB pins to 1 ' POKE PORTB,255 ' ELSE ' ' If PORTA.0 is 0 then place all PORTB pins to 0 ' POKE PORTB,0 ' ENDIF GOTO START
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks