View Full Version : Hi-Z input port
panorama
09-18-04, 12:33 AM
Hi,
I am trying to create a serial bus to talk to an external device using a clock line and data line. The data line is bi-directional. When receiving, I must put the data line to a Hi-Z state so the other device can set the value. From the Motorola manual, I could only find the timer's as having the ability to create a Hi-Z state, but it seems that all 6 timer ports will be placed in Hi-Z at one time, meaning I will "waste" all the other 5 timer pins.
What happens when configuring a GPIO pin as input? Does that create a Hi-Z state as well?
Thanks.
Tim
RMDumse
09-18-04, 05:20 PM
You should have a look at the User's Manual DSP56F801-7UM.pdf, Chapter 7 GPIO. Each GPIO port has a number of registers that control its operation. First, it has a peripheral function, or a port function, so it will normally need to be released from its peripheral function. It has a data direction register to control whether it is an input or an output. When it is an input, it is close to hi-Z, but still has a weak pull up. Usually this will work fine with an normal bidirectional output, but it you wish, it even has a register to turn off that pull up.
In IsoMax(TM) when you do an output function, like ON, OFF, SET or TOGGLE, the port pin is made an output. When you do an input function like ON? or OFF? it is made an input. If you wish to get rid of the weak pullup, you will need to go directly to the port's register an manipulate them yourself.
panorama
09-19-04, 05:00 PM
Thanks, yes, that is the manual I referred to, but it doesn't mention Hi-Z or tri-state in connection with GPIO.
Another problem has cropped up. When I do this:
1 E03 !, it takes about 10 us. I was pretty shocked by this, as I thought a 40 MHz chip should manage at least a 1 us, even with the Forth overhead. Is there any way to make it run considerably faster? I need to do 32 such operations in under 90 us for the clocked serial bus I am building.
Thanks, Tim.
RMDumse
09-19-04, 05:21 PM
To me, that's not too surprizing. You are executing 3 definitions and 5 words in a row there. What gets compiled is (LITERAL) (1) (LITERAL) (E03) (STORE). That's a lot of trips through NEXT.
The good news is we already provided a high level construct for situations like this. Look at trinaries. They allow setting or clearning any bits at an address with only one pass through NEXT. Try this.
DEFINE 1>E03 SET-MASK 01 CLR-MASK FE AT-ADDR 0E03 FOR-OUTPUT EEWORD
And the backup news is you can always insert machine code inline in the Forth.
panorama
09-23-04, 11:44 AM
Randy,
Thanks for your input. I had a hard time getting it right, but it finally works. I tested the trinary write operation at about 3us, and the read at somewhat less, but it is pretty hard to find out the exact speed.
One problem of note is that when reading from a port without pull-up, you MUST write a zero to that port first, otherwise you will read only ones. This drove me crazy for awhile.
Tim
RMDumse
09-23-04, 04:34 PM
Oh, that's interesting. We were getting some odd results a while back and it may have been just what you say. I'll keep an eye out for that now. Thanks.
vBulletin v3.0.7, Copyright ©2000-2012, Jelsoft Enterprises Ltd.