Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple output port error

Status
Not open for further replies.

Jimbobjeff85

Programmer
Apr 21, 2004
2
0
0
GB
Ok, I am writing a simple program for Motorola GP HC608.
My problem is basically I set PortB as output port and store 00 in it, which works, then when ever I try to load
values into the acumulator, and then store them in port b, it wont write them.

Here's my program up until the error:

$Include 'c:\pemicro\ics08gpz\gpregs.inc'



RAMStart EQU $0040
RomStart EQU $E000 ; This is valid ROM on the GP20 and GP32
VectorStart EQU $FFDC

org RamStart


org RomStart




;**************************************************************
;* Main - This is the point where code starts executing *
;* after a RESET. *
;**************************************************************



; MAIN PART OF PROGRAM
start
lda #$07 ;loads accumulator (temporary storage)
sta DDRB ;store contents of accumulator in DDRB
lda #$00 ;loads accumulator (temporary storage)
sta PortB ;stores contents of accumulator in Port B

startflash
redloop ldx #$12 ;stores 12 in x register,
lda #$08 ;loads accumulator with value 3
sta PortB ;stores accumulator in PortA,
jsr ondel ;jumps down program to subroutine "ondel"
lda #0 ;loads 0 into acumulator
sta PortB ;stores 0 in PortA removing red light
jsr offdel ;jumps to subroutine off delay for
dbnzx redloop ;goes back to beginning of loop
 
hello,

i notice the annotations say portA when portB is written.

a couple of things to consider (if not already)

is zero a valid port code?

sometimes another register is used to set the port mode.

some port commands require a series of bytes to complete and before another command will be accepted.

good luck!
straiph


"There are 10 types of people in this world, those who know binary and those who don't!"
 
As far as I know, 0 is completely valid, as colleagues have used it ok, and also when the program runs, loading 00 turns output port to 0.

As for using another register to set port mode, are you infering i use the index register to set value to the output port?

Other than that, you've confused me a bit.
 
hmm, didnt mean to confuse you. i havnt got technical data but i was hoping to give you an eye opener as to what the problem is.

more than 1 register port... sometimes ports come as a pair, 1 is the control and the other is the data. you set a particular value in the control port, for example configuring the data port for input, output and so on.

also, sometimes the first byte written to a port is the command byte which then tells the device to expect another or more bytes of information to be written.

what i would do... get the technical information on the device you are communnicating with through the port ie a list of codes and data frames. this should prove weather you are communicating with the device correctly. if it still doesnt work then i would contact the device manufacturer. after all, your processor and/or device could be faulty.


"There are 10 types of people in this world, those who know binary and those who don't!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top