|
|
| Author |
Message |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR
|
|
Posted: 13 July 2010, 23:00 PM Post subject: |
|
|
| Incidentally, you could replace the two consecutive PutPin() calls with one using the zxOutputPulse mode. Also, you should initialize pin 89 to be zxOutputHigh before entering the loop. This is essential if you use the pulse mode but it should be done even with the two PutPin() calls. |
|
| Back to top |
|
 |
Paul Lamar
Joined: 14 May 2010
Posts: 46
|
|
Posted: 14 July 2010, 0:58 AM Post subject: |
|
|
Thanks for the bit pulse tip Don.
I am really jazzed about this register direct manipulation.
IMHO It is an unprecedented simple marriage of asm and BASIC.
Writing or reading an I/O register direct is a super fast way of setting
and reading a bit.
I will use that for most of what we are doing as we only have about
8 ms for the entire program.
Thanks again for educating me and implementing Register dot.
Paul Lamar
www.rotaryeng.net |
|
| Back to top |
|
 |
spamiam
Joined: 13 Nov 2005
Posts: 689
|
|
Posted: 14 July 2010, 1:55 AM Post subject: |
|
|
| dkinzer wrote: | | Code: | addr[1] = 0; // make all bits inputs
addr[2] = 0; // turn off pullup resistors |
|
I think you have to be careful with this approach. I seem to recall that for some port memory mapings of the DDR and PORT and PIN are not sequential locations. You need to double check for each port on a specific processor.
Also, I have found that it may take a one (or more?) clocks for a PIN to settle on a new value after changing. In the my specific case, I was scanning rows of a keypad. I would set a specific pin high or low to a row, then read the column using a different pin. I would have to insert a NOP between instructions for setting the scanning pin and reading the input pin.
It may take a clock to have the PIN settle after changing the DDR in order to get a very reliable reading.
-Tony |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR
|
|
Posted: 14 July 2010, 2:11 AM Post subject: |
|
|
| spamiam wrote: | | I seem to recall that for some port memory mapings of the DDR and PORT and PIN are not sequential locations. | Your caveat is well taken, generally speaking. However, all of the mega chips used for ZX devices have sequential registers (PINx, DDRx, PORTx) except for the mega128 and on that chip only PINF is out of place.
| spamiam wrote: | | Also, I have found that it may take a one (or more?) clocks for a PIN to settle on a new value after changing. | There are two factors that contribute to a delay before reliable PINx read may occur. The first is the "synchronizer" on the AVR inputs consisting of two D-flops. The second factor is I/O line capacitance. The strength of the drivers on the other end the magnitude of the capacitance of the wiring may introduce additional delay until the level at the AVR pin moves above the logic 1 threshold or below the logic threshold. |
|
| Back to top |
|
 |
Paul Lamar
Joined: 14 May 2010
Posts: 46
|
|
Posted: 14 July 2010, 11:06 AM Post subject: |
|
|
I suggest using two or three Register Dot's in a row if width or settling is a problem.
Still faster than the traditional approach. However I have not tried it yet.
BTW I implemented an 8 bit counter and was able to read it and send the data
out to the USB at 500 counts per second with out missing a count. Not too useful
but a check on the idea. Of course the big delay was Debug.Print. My USB won't go any faster than 19,200. The time taken by Debug.Print was a function of the count.
Low counts are faster as it sends only one character.
Paul Lamar
www.rotaryeng.net |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR
|
|
Posted: 14 July 2010, 14:59 PM Post subject: |
|
|
| Paul Lamar wrote: | | Low counts are faster as it sends only one character. | If you send the value in binary then all counts are one character. | Code: | | Debug.Print Chr(count); |
An alternate strategy is to interact directly with the output queue, eliminating the interim conversion to a single byte string. | Code: | Dim count as Byte
Dim outQueue() as Byte Based Register.TxQueue
Sub Main()
Call PutQueueByte(outQueue, count)
End Sub |
|
|
| Back to top |
|
 |
Paul Lamar
Joined: 14 May 2010
Posts: 46
|
|
Posted: 14 July 2010, 15:13 PM Post subject: |
|
|
Thanks Don.
Paul Lamar |
|
| Back to top |
|
 |
|