Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 10, 2024, 05:09:52 05:09


Login with username, password and session length


Pages: [1]
Print
Author Topic: input command?  (Read 5722 times)
0 Members and 1 Guest are viewing this topic.
kctan
Guest
« on: November 23, 2005, 08:18:24 08:18 »

i am new and i write the input code in microcode studio plus like this
 
define osc 20
trisa = %111111
trisb = %00000000
x var byte
start:
   if porta.0 = 1 then
   portb.0 = 1
   else
   portb = %00000000
   endif
when i simulate in proteus 6 the output is nothing
when i was press a switch in proteus it got signal go in voltage is 5.33 after i open that switch i find that porta.0 pin still got voltage that is 3.44 wat is the problem
wat's wrong with my coding?
 
define osc 20
trisa = %111111
trisb = %00000000
x var byte
start:
    x=0
    while porta.0 =1 and x = 10
    portb.0 = 1
    x=x+1
    wend
with this code i'am also cannot work so wat is my problem in input?
Logged
picstudent
Active Member
***
Offline Offline

Posts: 169

Thank You
-Given: 0
-Receive: 3


« Reply #1 on: November 23, 2005, 06:17:14 18:17 »

brother i think you must write the bynary complete the 8 bits you know  %11111 ?
Logged

... rego ... who are are you really ?
freddyg
Junior Member
**
Offline Offline

Posts: 85

Thank You
-Given: 3
-Receive: 2


« Reply #2 on: November 23, 2005, 08:28:18 20:28 »

picstudent, there's no need to supply all 8 bits. Any missing high-order bits are assumed to be zero, so in this instance, porta.0 to porta.5 are inputs,

In the first code, there's no loop so the code will shoot through once then fall off the end. Is this the complete code? If so, there needs to be something to stop processing at the end.
eg.
end:
  goto end

If you haven't got this, the processor is looping right through memory and is crashing. A voltage of 3V or so would imply the pin is floating (ie. has become an input) or is bouncing up and down quickly. Either way, your code has fallen off the end and the processor is performing a big loop around the full address space.

In the second piece of code,
Quote
define osc 20
trisa = %111111
trisb = %00000000
x var byte
start:
x=0
while porta.0 =1 and x = 10
portb.0 = 1
x=x+1
wend

this won't do anything because x starts at 0 but your while loop will only perform if x=10, so it will never go into it.


Freddy
« Last Edit: November 23, 2005, 08:33:23 20:33 by freddyg » Logged
freddyg
Junior Member
**
Offline Offline

Posts: 85

Thank You
-Given: 3
-Receive: 2


« Reply #3 on: November 23, 2005, 08:39:25 20:39 »

One more thing. I'm assuming you are using pic basic pro.
In which case,  the "define osc" statement is case sensitive, so should say
DEFINE OSC 20
otherwise it will be ignored (see page 30 of manual) and will default to 4MHz.
« Last Edit: November 24, 2005, 08:56:03 20:56 by freddyg » Logged
kctan
Guest
« Reply #4 on: November 24, 2005, 05:47:46 05:47 »

Quote from: picstudent
brother i think you must write the bynary complete the 8 bits you know %11111 ?
because i saw at the datasheet in pic16f877a only got 6 pin at porta, should i declare extra one?:confused:
Logged
kctan
Guest
« Reply #5 on: November 24, 2005, 05:50:05 05:50 »

Quote from: freddyg
One more thing. I'm assuming you are using pic basic pro.
In which case, the "define osc" statement is case sensitive, so should say
DEFINE OSC 20
otherwise it will be ignored (see page 20 of manual) and will default to 4MHz.
thanks for u all helping. i will try the command.
regards
KC:D
Logged
tasosstr
Junior Member
**
Offline Offline

Posts: 75

Thank You
-Given: 95
-Receive: 14


« Reply #6 on: November 24, 2005, 05:54:52 17:54 »

Did you try Portb = 0 ? has the same result ?
Logged
kctan
Guest
yes
« Reply #7 on: November 28, 2005, 10:03:05 10:03 »

Quote from: tasosstr
Did you try Portb = 0 ? has the same result ?
i try all port by using the proteus 6.7 simulate
is better by using the proteus to simulate?Cheesy
Logged
tasosstr
Junior Member
**
Offline Offline

Posts: 75

Thank You
-Given: 95
-Receive: 14


« Reply #8 on: January 02, 2006, 08:51:56 20:51 »

Yes or you can use microcode studio
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC