Thursday, 10 October 2019

Logic Level Shifters - Practical things of the BBB

Logic Level Shifters (on the BBB)

 

The Beaglebone

Using the BeagleBone PRU_1 as inputs, you have to take care of what other functions are also present on the pins. For example, the PRU1 0..8 pins are also BOOT configurations! These pins tell the BBB what to do on powering up.There is a specific combination of pull-up and pulldown resistors on the port to setup modes for the CPU.

When adding level shifters to these pins - be aware!


The Simple FET shifter (Bidirectional)


Using a device from EBAY, the FET can be used - but you need to know what it is doing..


From the circuit, you can see that R3 is a pullup. Adding this will override the BBB's on-board BOOT strapping if you use it on PRU_1 and you may notice that your board will fail to boot. 







Zener Clamps 

Conclusion : Not suitable for high speed logic

For a simple unidirectional clamp, a 3.3V Zener diode can be used to limit the voltage.There are 2 components - cant be easier! - if you have Zener diodes to hand!

So far I am favouring the above circuit - I have to confirm that it can handle the speed I need and it doesnt skew the signal edges.

After some tests - this is unsuitable for high speed using the components I had to hand.

The blue trace is the 5V signal, the yellow is the output to the Beaglebone - this is not good.




TXS0108E

NOTE!  there are 2 different versions.. TXS and TXB - One is for open collector and the other is for Push-Pull. I bought the Open collector version.. Wrong part for a BUS configuration.

A range of chips from TI are available for the purpose of level shifting.



You can buy read made tiles from EBAY and other online shops.





From the Breakout,  there is quite a special feature that is available when using this chip. On the bottom right is an OE signal input. This allows for the outputs of the level converter to be tri-stated to Hi-Z and only when the BBB cpu has completed its bootup, this pin can be asserted which wakes up the converter. 

This allows for the PRU1 bus to be 'left disconnected' until linux is running, which at that point I can switch on using a GPIO 



I have now settling on...
 
 
TEXAS 
lNSTRUMENTS 
б Pin Configuration and Functions 
DB, OW, ОН pw PACkAGE 
[тор 
SN74LVC4U5A 
scAS375I -МПСН lY9'-REWSED lANUARY 2015 
А4 
Аб 
GND 
GND 
10 
12 
24 
23 
21 
20 
18 
17 
16 
15 
13 
\Јссв (3,3 М) 
VccB (3.3 М) 
81 
вз 
84 
GNO 
МАМЕ 
VccA 
GNO 
GNO 
GNO 
Vcc8 
Vcc8 
Pin Functions 
DESCRlPT'0N 
Pouer supply for side А 
Directjon сог*го• 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 
Ground 
Ground 
Ground 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
Transceiver 1/0 pf 
0utput ЕпвВ'е 
Pouer supply for side В 
Pouer supply for side В

 
 



Monday, 2 September 2019

Amiga to BeagleBone Black


 


Amiga 500 Zorro to BeagleBone Black

My Ramblings...

These are my thoughts on how to get an interface from an Amiga500 to a Beaglebone. The diagrams may not work at all, but they help me visualise the problems of interfacing. 


There are many challenges, the BBB has got limited PRU high speed IO lines - so I have opted to multiplex them. Additionally, BBB runs at 3v3 - and the Amiga is 5V; there will be many level converters but I am keeping it brief for now.

The Multiplex - Address Lines

For the one port, bytes are sampled in 3 clocks. This is typically with the ADDRESS SELECT line becomes VALID. This will signal the PRU to sample the values and check for an address in the most significant byte. 
I am trying to avoid a CPLD, but if needed I will offload the Address decode to one if I cant get it to run fast enough.

I should be able to latch all the addresses within 60nSeconds using just the PRU

Amiga 500 Main Clock (PAL variety)

 

Prototyping Board (Zorro connector) - with BBB attached

 I managed to source a connector - and soldered to a Prototyping board. Bending the pins on the connector to make it right angled was a tiresome task.. and getting all the pins though the holes was a challenge when all the legs have a mind of their own


 

The DATA bus buffers

As the BBB does not have fast switching of INPUT and OUTPUT, a multiplex was chosen so that all INPUTS are on one set of pins.. and outputs on another.

All reads are muxed to PRU0 and Writes are to PRU1. 74HCT573 latches are used to put lock the data on the bus in preparation for reading from the master - and after read the pins are set to high impedance as to not mess with the data in the case of a read. 


  Address and Some MUXing action..

Amiga timing 

From the charts, it looks like 300nSeconds is average... but 200nSeconds was seen on my scope? Either way.. I was aiming for 200nSeconds as a maximum




 

 

 

 

Friday, 30 August 2019

BeagleBone Black PRU

BeagleBone Black - Adventures with PRU

 Part of 'How fast can you make a GPIO toggle, I have now just done a torture GPIO toggle on BeagleBone just to see how fast it can run.

From the looks... it may just do the trick! - hopefully emulate a RAM chip and peripherals in an Amiga!

The Setup,

From The PRU guide on Element 14 the setup is pretty straight forward main difference is you dont need to install the code composer studio as the BBB gets configured with all the PRU software. What you do need are the samples; and put them anywhere you like.

 Update the kernel - nice but not really needed
  1. sudo /opt/scripts/tools/update_kernel.sh  
  2. sudo apt update  
  3. sudo apt upgrade  
  4. sudo apt dist-upgrade 
Connect to the BBB and link the compilers and do the export.
ln -s /usr/bin/ /usr/share/ti/cgt-pru/bin
export PRU_CGT=/usr/share/ti/cgt-pru

Next to get the sample code from GIT

git clone git://git.ti.com/pru-software-support-package/pru-software-support-package.git 
Change to the directory with the examples downloaded in the previous step - and run the makefiles
cd /opt/source/pru-software-support-package/examples/am335x
make
 Once compiled, set the IO pins
sudo config-pin P9_27 output
sudo config-pin P9_27 pruout
 and then copy the firmware files to /lib/firmware on the BBB

cd /sys/class/remoteproc/remoteproc1
 echo '<firmware name>' firmware
 echo 'start' > state
*NOTE - the example in the download does not toggle P9_27 - change to 0x0020 in the sources ffor gpio.

From the small application - Toggling P9_27; there is 25nSecond for one pulse. Loaded in to the PRU and voila!

#include <stdint.h>
#include <pru_cfg.h>
#include "resource_table_empty.h"

volatile register uint32_t __R30;
volatile register uint32_t __R31;

void main(void)
{
        volatile uint32_t gpio;

        /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
        CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;

        /* Toggle GPO pins TODO: Figure out which to use */
        gpio = 0x0020;
        while (1) {
                __R30 ^= gpio;
//              __delay_cycles(100000000);
        }
}
 
From the FFT trace - there is all sorts of frequencies in there.. the harmonics are awesome!


Update:

Even without using high speed PRU GPIO pins, the access to normal pins from the PRU is still quite a respectable 80nSeconds. (ignore the yellow trace, its connected to the high speed line which is doing nothing)


Avaliable Pins on a BeagleBone Black




STM32F4 Interrupt latency - how fast can it go

STM32F4 - Interrupt latency

Following on from the ESP32, (ESP32 Interrupt Latency) I had a STM32F401RE Neucleo board lying about.. this was the next test bed for how fast can an interrupt go; and how fast can it manupulate a GPIO. Using OpenSTM32 development package and in C (no assembler yet)

First try - Using an Interrupt

My first experiment was with INTERRUPT routines. This shows how long it takes for the STM32F4 to act on an ISR  - 3uSeconds from the trace.


The YELLOW trace is the GPIO line dropping, the CYAN trace is another pin being cleared within the ISR function. I have a target of 100nSec to reach; I think that target is a bit much for this CPU


How fast can it actually toggle?

One thing I didn't look at was how fast the pin can be toggled.


Hmm... ~300nSecond for one pulse- and that is a while(1) set clear set clear loop using register access.  If the chip cant toggle at a fast pace, I dont think I have any hope reading a GPIO in a busy-wait loop.

Conclusion

The STM32F4 CPU isnt quick enough to interface directly to an 8Mhz bus on the Amiga. 

NEXT

The BeagleBone PRU speed ... https://gruhouse.blogspot.com/2019/08/beaglebone-black-adventures-with-pru-of.html