What is idle state of MOSI when programing a 9x? --Answered

Post Reply
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

What is idle state of MOSI when programing a 9x? --Answered

Post by rperkins »

UPDATE
Question answered in this post.
viewtopic.php?f=10&t=705&p=10076#p10076

I'm still having issues with my cheap ebay usbasp programmer locking up. I have to disconnect/reconnect the usb port to get it working again. I dont have an issue when I connect two of these units back to back, with one of them in programming mode ( jumper 2 installed ). However when I hook the usbasp programmer up to the 9x, I have problems.

I also have a bus pirate which does not hang up when communicating with the 9x. The standard firmware is on the bus pirate, not the alternate firmware that mimics a stk500. The bus pirate works at about 1/10 the speed of the usbasp.

What I have noticed is the idle state of the MOSI pin varies between the usbasp and the buspirate. When communicating with the 9x , MOSI idles low with the bus pirate, MOSI idles high with the usbasp. the sck and miso have the same polarity with both devices. I reviewed the atmel datasheet and it talk about the clock polarity, but if it mentions the MOSI polarity, it went over my head. I have two usbasp's. One still has the locked chinese firmware and the other has vanilla usbasp firmware. both versions have reversed MOSI polarity when compared to the bus pirate.

I dont think this is the main issue because even when the usbasp works properly the idle state is high. I just want to follow up on it. What I have noticed is the MOSI pulses are wrong when the usbasp does not work.

So can anyone shed some light onto the polarity of the MOSI when programming a 9x ?

I can provide LA/oscope pics/exports if requested. avrdude is the software being used.
Thanks
Last edited by rperkins on Wed Apr 25, 2012 8:13 pm, edited 1 time in total.

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: What is idle state of MOSI when programing a 9x?

Post by rperkins »

So I am thinking that a capacitor on the MOSI line of the 9x getting charged when doing high speed SPI. Could that be why it is idling high when doing high speed programming with the usbasp. The MOSI pin on the 9x is pin 1 (PE0). During normal operation of the 9x this pin is used for something called ADROT or Tcut_SW, depending on which schematic you are looking at. One of the schematics shows a .1uf capacitor (C114) going from pin 1 to ground. Could this capacitor be charging the MOSI line and making it idle high ?? What is it's purpose in the circuit ?

Basically the usbasp will work the first time it is plugged into usb and attempt to interact with the 9x through avrdude. I can watch on the scope and after the data is sent it takes a couple seconds for the line to drain back to 0 volts. ( dc coupling on scope ) . Sometimes if I wait a few more seconds, a second command will be successful. Usually the susbsequent commands fail because avrdude reports that the signature is wrong. If I continue to try then it completely fails to communicate with the 9x. Unplugging the usbasp from the usb port, and plugging it back in resets the whole issue.

I followed up as so. Usbasp has an option to lower the speed of SCK. You put a jumper on JP3. This is for when you have a virgin atmel chip that has the fuses set for an internal 1mhz? oscillator. The SCK has to be no faster than 1/8th? of the oscillator. Now the chinese usbasp boards I have dont have JP3 because their firmware has a special *autospeed*. JP3 basically shorts pin 25 (PC2) to ground. So on the chinese usbasp that I reflashed with standard usbasp firmware, I shorted pin 25 (PC2) to ground and was able to reduce the SCK significantly. Now the MOSI is idling low and the usbasp is stable when hooked to the 9x. No issues at all. I can remove the JP3, which reverts me to high speed, use one usbasp as the programmer to read another usbasp ( J2 attached ), and dont have any issues. It is only when trying to program the 9x in high speed , that the usbasp programmer is unstable.

Yes I have tried short leads (3 inches) and it didnt make a difference. I've used long leads ( 12 inches ) when hooking the usbasp's together, and havent had any issues.

thanks for reading along.
User avatar
cre8tiveleo
Posts: 1434
Joined: Tue Dec 27, 2011 6:13 pm
Country: -
Location: Ontario,(GTA North)
Contact:

What is idle state of MOSI when programing a 9x?

Post by cre8tiveleo »

Change your usb cable to a shorter one, under 6 inches, and/or , use one that has two plugs at the computer end, one is data/power , the other is just more power.
I have 4 hk programmers and the only time i have issues is when i use a crappy usb cable. All cables are NOT created equal.
Same with programming my flight controllers. Only use a dual lead usb short 6 inch cable, always works.



---
I am here: http://tapatalk.com/map.php?jz2fkr
User avatar
Peter
Posts: 232
Joined: Thu Dec 29, 2011 8:45 pm
Country: -
Location: Zuid-Holland

Re: What is idle state of MOSI when programing a 9x?

Post by Peter »

Could the reversed idle polarity be caused by the bus pirate startup mode? The bus pirate starts in high impedance mode afaik. After he detects that it needs to be in programmer mode, it could change the idle mode?

Sent from my Galaxy S2 using Tapatalk 2
ReSt
Posts: 1581
Joined: Tue Dec 27, 2011 11:34 pm
Country: -

Re: What is idle state of MOSI when programing a 9x?

Post by ReSt »

I would try to put a resistor of, lets say, 1 - 10 k (try different values) parallel to C114 to have a defined discharge path for the capacitor.

Check if that changes anything


Reinhard

User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: What is idle state of MOSI when programing a 9x?

Post by Kilrah »

Where does your usbasp come from? Some seem to have gotten ebay ones that don't really work...
Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: What is idle state of MOSI when programing a 9x?

Post by Romolo »

I have tried up to now 10 usbasp from different sources, only one was defective due to poor quality crystal.
What I have noticed up to now in that the cable length is one of the most important things...
I actually modify radio by putting the usbasp internally to the radio with very short cable and no connector at all.
(crimping on the flat cable is another point of failure)
User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: What is idle state of MOSI when programing a 9x?

Post by gohsthb »

The idle state of the MOSI line doesn't matter. At least it is not specified in the atmega64 datasheet. When the usbasp is transmitting data does the waveform have nice square edges? Or is it triangular? If the edges are nice and square your problem is elsewhere. Have you had a look at the reset line? I know my avrispmkii complains if I leave the 10uF capacitor on the reset line. The programmer thinks the line is shorted because it cannot change the reset state fast enough. You can remove the 10uF cap on the reset line. It serves no purpose there anyway.
-Gohst
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: What is idle state of MOSI when programing a 9x?

Post by rperkins »

thanks for all the replies. I removed the capacitor I mentioned and did not fix the problem. It did allow the MOSI line to return to 0 volts faster though. The MOSI still looks like it is idling high when transmitting usbasp high speed data though ?

regarding a shorter usb cable. I do have a 3ft or so usb extension cable on there, then I had a hub. I was able to remove the hub but will have to rearrange things to do a test without the extension cable.

regarding a shorter SPI cables. In the end I am going to install the usbasp inside my radio, so I have had very short ( 3 inch ) wires on there. I am using solid wire from cat5 cable. I have removed the usb plug and am using .1 headers. I had removed the SPI plug and soldered directly to the board, but reinstalled the plug since I needed to run down this issue. I dont want to have a problem after I get the usbasp installed and the transmitter all buttoned up. :)

regarding using a resistor. That was a good idea. It helped me to see the charge drop off faster. When it didnt fix the problem I removed the smd capacitor. That didnt work either. I saved the cap and hopefully can reinstall it.

I have 2 usbasp's. got them off of ebay. http://item.taobao.com/item.htm?id=10052532429 . One I reprogrammed with the standard usbasp firmware. the other still has the chinese firmware. One I got did have a bad crystal also. Not sure if it arrived DOA or if the crystal died from shock or whatever. I used another 12mhz crystal out of something else and brought it back to life. When I put these 2 units back to back, with one in programming mode, they work fine.

Tomorrow night I think I will compile some usbasp firmware with different speeds. the source looks like it is setup for as many as 10 speeds, but I havent seen a way to control it yet without recompiling. avrdude has some 'delay' options, but I havent seen any 'speed' options.

What I have right now and see on scope and logic sniffer

Bus pirate is at 31 khz SCK and the MOSI idles low. works good but very slow.
USBasp with J3 (slow SCK) is at 5.6 khz and the MOSI idles low. works good but slow.
USBasp default is at 375 khz and the MOSI idles high. only works once then needs usb removed. reinserted.


Question for you guys that have your programmer installed inside or have a plug to access it. What happens if you try to program your 9x with the throttle_cut switch engaged. This is the switch on the back left hand side. Can you program at all when in that state because the MOSI pin is being pulled low through the 200? ohm resistor ??

thanks again for all the comments. I think I like this better than flying the heli, although warm weather is almost here in Cleveland. No wind is another story.
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: What is idle state of MOSI when programing a 9x?

Post by rperkins »

gohsthb wrote:The idle state of the MOSI line doesn't matter. At least it is not specified in the atmega64 datasheet. When the usbasp is transmitting data does the waveform have nice square edges? Or is it triangular? If the edges are nice and square your problem is elsewhere. Have you had a look at the reset line? I know my avrispmkii complains if I leave the 10uF capacitor on the reset line. The programmer thinks the line is shorted because it cannot change the reset state fast enough. You can remove the 10uF cap on the reset line. It serves no purpose there anyway.
-Gohst
Thanks for the reply. I will check on this tomorrow . got to get some sleep before work now
User avatar
cre8tiveleo
Posts: 1434
Joined: Tue Dec 27, 2011 6:13 pm
Country: -
Location: Ontario,(GTA North)
Contact:

What is idle state of MOSI when programing a 9x?

Post by cre8tiveleo »

rperkins wrote:...

regarding a shorter usb cable. I do have a 3ft or so usb extension cable on there, then I had a hub. I was able to remove the hub but will have to rearrange things to do a test without the extension cable.
... all when in that state because story.
... :|
User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: What is idle state of MOSI when programing a 9x?

Post by gohsthb »

The speed option for avrdude is '-B 100'. The number determines the speed. 100 is pretty slow but always seems to get things working if it is a speed issue. However some programmers will simply ignore the -B option, but it doesn't hurt to try it anyway.
-Gohst
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: What is idle state of MOSI when programing a 9x?

Post by Kilrah »

rperkins wrote:Question for you guys that have your programmer installed inside or have a plug to access it. What happens if you try to program your 9x with the throttle_cut switch engaged. This is the switch on the back left hand side. Can you program at all when in that state because the MOSI pin is being pulled low through the 200? ohm resistor ??
No problem to flash with the switch on here with my integrated usbasp.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: What is idle state of MOSI when programing a 9x?

Post by jhsa »

that's how I do.. my programmer is set no to provide power to the radio.. I flash with the radio on.. somehow I have more confidence this way..
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: What is idle state of MOSI when programing a 9x?

Post by rperkins »

Thanks for all the replies. Haven't been able to get back on it but;

Usbasp doesnt respond to the -B switch from avrdude. I did find a patch from 2007mthat adds this. Dont think it was ever applied.

Thanks for the success stories regarding the switch position.

Removing the usb cablendid help. But it still misreads 5% of time.

I had an osc. Fail in one of my 2 unitsn. Dont remember which one. When i was verifying 12mhz freq. One osc has a much higher p-p voltage. I remember the fuse bits talking about the type of osc.
Attachments
bb042012183136.jpg
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: What is idle state of MOSI when programing a 9x?

Post by rperkins »

rperkins wrote: Usbasp doesnt respond to the -B switch from avrdude. I did find a patch from 2007mthat adds this. Dont think it was ever applied.
I was wrong about this. I was looking at a patches for avrdude/usbasp.* but trying to find the changes in usbasp/usbasp.* :oops:

I do think this is a true statement:
Some of the usbasp adapters for sale on ebay that have chinese firmware loaded on them do not respond to the -B switch from avrdude. They will generate a warning "warning: cannot set sck period. please check for usbasp firmware update" . This warning can be ignored. The chinese firmware tries to automatically set the speed and ignores speed setting from avrdude. If you have another programmer available and want to be able to control the speed from avrdude, overwrite the locked chinese firmware with vanilla usbasp firmware.
rperkins wrote: One osc has a much higher p-p voltage. I remember the fuse bits talking about the type of osc.
It wasnt that one oscillator had a higher output than the other. The output is controlled by the fuse settings. A higher output setting should work better in noisy environments and when you want to use the oscillator circuit to drive other chips. The lower output setting saves power but the oscillator can not drive other chips.

outa time
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: What is idle state of MOSI when programing a 9x?

Post by rperkins »

Back to my original question. I think that when using usbasp with the standard firmware the mosi idle state depends on the speed of the SCK (clock). At 93khz and above the standard usbasp firmware transmits the data thru the spi hardware 9nterface. This results in mosi idling high. At below 93khz sck the firmware transmits the data via software, one bit at a time. This results in mosi idling low. Here is a crude video showing this, although the usbasp is communicating with an arduino, not a 9x.
http://www.youtube.com/watch?v=qyyQICsNEgc
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: What is idle state of MOSI when programing a 9x?

Post by rperkins »

gohsthb wrote: Have you had a look at the reset line? I know my avrispmkii complains if I leave the 10uF capacitor on the reset line. The programmer thinks the line is shorted because it cannot change the reset state fast enough. You can remove the 10uF cap on the reset line. It serves no purpose there anyway.
-Gohst
This was the reason why I was having trouble using my usbasp with the 9x. I dont think mine was a 10uf either. I have a couple schematics for the 9x. The one I looked at tonight did call out this part as a 10uf. However the part I removed is marked 'J476'. No it's not the 47uf cap over by the regulator. It's right there on the reset line down under where the crystal is located. I can post a pic if needed.

After removing this cap I dont have any errors reading the 9x. Yes a shorter cable on either side helped marginally, but removing this cap made all the difference in the world. I wish I woulda took your advice sooner :)
thanks
I've been after this for awhile
Randy

I'm so pumped I think removing this cap should be standard procedure when wiring up a 9x for a programming port :) :)
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: What is idle state of MOSI when programing a 9x? --Answe

Post by MikeB »

It does depend on your programmer. I use a STK500, which initially would not work except at very slow speed. I built a buffer board, with 74AC08 devices for driving the outputs. They are so powerful that it now programs at full speed, and copes with the capacitor on the reset line.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

Post Reply

Return to “PROGRAMMERS”