How to connected onto an in circuit Bus - Page 1
Forum section: electronics / projects

author: Docara
author_rank: Regular Contributor
timestamp: February 25, 2021, 01:36:53 pm
content: HiCan't really find the answer to this easily anywhere.So you have built a project which contains (insert here- I2C, SPI, UART whatever) between a device(s) and an MCU.How do you then connect an external programmer, say, onto this bus without it affecting other things on the board? Presumably you would put resistors in line on all lines of the bus, but if this is the case how do you calculate values.Some links or general rules of thumb would be greatly appreciated.Thanks

author: Ian.M
author_rank: Super Contributor
timestamp: February 25, 2021, 01:52:53 pm
content: Why would you want to? Generally its easier to simply have the MCU program devices on the bus with non-volatile state, and for the MCU itself to use whatever is its native in-circuit programming interface other than the bus. If the MCU's got limited program memory, you may need to first flash configuration firmware to set up all non-volatile devices then flash the actual operating firmwareHowever if you need to seize the bus e.g. to program a FLASH chip the MCU will boot from, for most MCUs its sufficient to hold them in Reset to make them tri-state the I/Os connected to the bus.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 25, 2021, 02:09:20 pm
content: Well, what programmer?MCU: just don't connect the programming port pins. Many have dedicated pins so this is trivial. Some have multiplexed ports where this applies (e.g. ATTiny, most ATMega).If you have to, yes, series resistors are a possibility; or hold the devices in reset, if they go tristate when so; or insert gates so any fixed drivers can be disabled.Peripheral, e.g. EEPROM:Pre-program it from the factory, or in a separate step before assembly. (More of a production thing, but it's surprisingly affordable even in sub-full-reel quantities.)Or, implement a test/prog mode on the MCU so it can be loaded through that.Or, implement a mode that tristates the bus, so an external adapter can drive it.Or, hold the MCU (or other master) in reset so it tristates the bus (this is usual behavior for most MCUs, check datasheet to verify).Or, add series resistors to driver pins, or gates to disable drivers.Note that bidirectional buses are harder to gate. A bus interface requires a direction control signal. If not available, there are still transmission gates (analog switch/mux) that can be used.Resistors: value depends on programmer current capability and bus speed.Minimum value:If the programmer has normal CMOS outputs, then it should be somewhere in the 20-100 ohm range, with 50-70 ohms being typical. So a valid logic level can be had, when a pin is loaded by say 200 ohms or more (to VCC/GND, point being you don't know which due to the fixed-output pin doing whatever it does).Maximum value:Bus and pin capacitance must charge in a reasonable fraction of a bit time. If the bus runs at say 10Mbps (100ns bit time, 5MHz clock), and there are let's say three pin loads of 10pF each, and the total trace length is 10cm (~5pF), then the total 35pF has to be driven in say 30ns (2 R C) so 30ns / 35pF / 2 = 428 ohms, let's say 470 would be enough.So for this case, 200-470 ohms would be acceptable.At a high enough bitrate, these ranges won't overlap and the method cannot be used.Higher bitrates should be handled by gates/switches. Including mechanical means like DIP switches or jumper blocks. Or simply solved another way.Finally, there are special cases for some buses. I2C is multi-master, you need only tell the MCU (or whatever other master is active by default) to piss off, then have at it. Similar for CAN. RS-485 buses are often used in a similar manner.Tim

author: Docara
author_rank: Regular Contributor
timestamp: February 25, 2021, 04:13:43 pm
content: Hi BothApologies, I realise I was vague and didn't give enough thought to the question before I posted.It was meant as general 'open-ended' question which would hopefully lead on to some specific info I could read up on. I think it would be prudent not to waste peoples time now and post a question with specific details when appropriate clearly - it seems to be, sum what, on a case-by-case basis.The background to the question was what should I have consider in a circuit if I want to implement some form of in-circuit programming without unplugging the MC but use the programming pins for other uses in normal use.Thank you both for spending the time to reply. You have both made some good additional points which I can take away - Reset & Tri-stating, Telling the MCU to "Piss-Off" of course I2C addresses are involved and using buffers to isolate the relevant pins during programming.Thank you again

author: Ian.M
author_rank: Super Contributor
timestamp: February 25, 2021, 04:54:57 pm
content: Generally, if you need to use the in-circuit programming pins for I/O it indicates you've chosen a MCU with too few pins. Exceptions include very high volume highly cost sensitive products, where you are getting the MCU factory preprogrammed with your firmware and shipped direct to your assembler, so you only have to wrangle with multi-use pins during development. Unless you resort to another header next to the programming header to let you use jumpers to connect the circuits sharing the programming pins as required for testing during development, the solutions that are workable are highly dependent on the precise specifications of the specific MCU and programmer as T3sl4co1l alluded to when he commented on isolation resistor value and trace capacitance vs frequency, which would be determined by the MCU/programmer combo. Another consideration is debugging. MCUs with debug interfaces frequently have them on pins shared with their programming pins, so if you use them for any essential function of the target board, you give up the ability to use in-circuit debugging if you have problems during development.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: February 25, 2021, 04:56:42 pm
content: Ah, then it seems my general response was as desired. ExcellentTim

author: Docara
author_rank: Regular Contributor
timestamp: February 26, 2021, 05:21:20 pm
content: With forums especially, it's often hard to post a meaningful question together with proper terms and phrases in order to get a meaningful answer or response back. Then there's times like this when a BS question was posted and by chance a pot of gold popped out the other side. The responses you guys gave, suggested an alternate direction and thus an 'acorn' which is now growing quite nicely thank you!I love this :-QuoteObvious when someone bothers to tell you that you're being a dick.!!!I am so grateful for the replies you both submitted. It also really helped me with a problem I had in another area (slightly related to the post).This place is great!Thank you both.