View previous topic :: View next topic |
Author |
Message |
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sun May 06, 2018 10:37 am Post subject: |
|
|
always write 1 to unused or un-programmed bits.
you also need to write fuse bits first, and lock bit last. _________________ Mark |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Tue May 08, 2018 9:59 am Post subject: |
|
|
Hi All,
I'm still having problms with setting the fuse bits. After writing the fuse bits low to CPU stops responding to any commands from the ISP. I've bricked 4 CPUs already and I don't want to kill any more
I've found a AVR Fuse Doctor (http://mdiy.pl/atmega-fusebit-doctor-hvpp/?lang=en) and I'll build one over the long weekend. Maybe then I can see what is actually being written to the chip.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Tue May 08, 2018 1:40 pm Post subject: |
|
|
Hi Ian,
Does the problem occur when the Fuse/Lock Bits are written &HFF? If so, then the problem is in the writing process.
If &HFF is OK, could there be a problem with LSB/MSB sequence?
x |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Tue May 08, 2018 2:56 pm Post subject: |
|
|
Hi enniom,
I'm not sure where the problem is. If I can get to the point that I can actually read the value I've written then maybe I can solve the problem.
I've got an idea to use a timer in CTC mode (on the Host) that generates a square wave signal that I'll feed into the external clock in pin on the slave. maybe this way I can at least see what the slave has.
If that doesn't work I'll build a AVR Fuse Doctor.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun May 13, 2018 8:52 am Post subject: |
|
|
Hi All,
Finally got round to testing the "external clock" for the slave and can now read the fuses:-
Code: | WirelessGT EVO 2 PCB test system
A...Program then test Chip
B...Run tests (automatic mode)
1...Program Chip
2...Verify Chip
3...Erase chip
4...Blank check chip
5...Chip information
6...Run individual tests (manual mode)
7...Enable external Clock recovery
q...Quit
Select option (1-7)5
Entering programming mode
Send AC 53 bytes, and got 00 00
Failed to enter programming mode. Check cable
WirelessGT EVO 2 PCB test system
A...Program then test Chip
B...Run tests (automatic mode)
1...Program Chip
2...Verify Chip
3...Erase chip
4...Blank check chip
5...Chip information
6...Run individual tests (manual mode)
7...Enable external Clock recovery
q...Quit
Select option (1-7)7
Enabling external clock
WirelessGT EVO 2 PCB test system
A...Program then test Chip
B...Run tests (automatic mode)
1...Program Chip
2...Verify Chip
3...Erase chip
4...Blank check chip
5...Chip information
6...Run individual tests (manual mode)
7...Disable external Clock recovery
q...Quit
Select option (1-7)5
Entering programming mode
Send AC 53 bytes, and got 53 FF
Program mode active
CPU Information
CPU Signature=001E9404
Lock bits=3F
Fuse bits=00
Fuse bits high=00
Fuse bits extended=C1
Calibration Byte=55
|
So for some reason Fuse Bits/high are set to 0, Looks as if I have an error in the write code. Lock bits are OK but the reast are totally screwed up.
I was expecting:-
Code: | FlashSize=16
LockBits=3F
FuseBits=DC
FuseBitsHigh=D8
FuseBitsExtended=F9
| Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun May 13, 2018 1:13 pm Post subject: |
|
|
Hi All,
I'm slowly going mad here. I seem to be able to Change the fuse bits, but whatever I write it always Ends up being 0.
Code: | CPU Information
CPU Signature=001E9404 <----------- Get the CPU Fuse information
Lock bits=2F
Fuse bits=02
Fuse bits high=D8
Fuse bits extended=F9
Calibration Byte=56
Setting fuse bits ACA0 00DC <--------------- Set the Fuse bits
Entering programming mode
CPU Information
CPU Signature=001E9404 <----------- Get the CPU Fuse information
Lock bits=2F
Fuse bits=00
Fuse bits high=D8
Fuse bits extended=F9
Calibration Byte=56 |
Note. When reading the vales for all fuses corresponds to the values that I'm reading with my ISP within Bascom.
And here's my Fuse write code:-
Code: | Sub Set_fusebits(byval Value As Byte)
'Function :: Write fuse bits
'Author : Ian Dobson
'Inputs : Value to write
'Outputs : None
'Limitations :
'Date : 11.4.2018
If Slave_reset = 1 Then
Active = Enter_program_mode()
If Active <> 1 Then
Print #1 , "Failed to enter programming mode. Check cable"
Exit Sub
End If
End If
Spi_write_word = &HACA0
Spi_write_word1 = Value
#if Write_fuses = 1
Shiftout Slave_mosi , Slave_sck , Spi_write_word , 1 , 16 , Spi_delay_long
Shiftout Slave_miso , Slave_sck , Spi_write_word1 , 1 , 16 , Spi_delay_long
#endif
Print #1 , "Setting fuse bits " ; Hex(spi_write_word) ; " " ; Hex(spi_write_word1)
End Sub |
Can someone see what I'm going wrong.
Note: The Slave CPU is a MEGA162.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Sun May 13, 2018 3:44 pm Post subject: |
|
|
Hi Ian
While it may not be a problem, note that the sub defines (Byval Value as Byte) which is then assigned to a Word. Dont know if this may cause a problem.
As I suggested earlier, what happens if you write back exactly the Fuse/Lock bits that initially exist? Are they corrupted by the Write? If so, then the Shiftout is doing something unexpected (may need to do a "Bit Bang" to see the problem?).
It may be interesting to see how the "master" and "target" are wired together.
[Edit: Shiftout uses Mode 1 with a delay. I inserted some info from Help ... only to highlight some other places to possibly look. That is the Mode and Delay:
Quote: | Option can be :
0 – MSB shifted out first when clock goes low
1 – MSB shifted out first when clock goes high
2 – LSB shifted out first when clock goes low
3 – LSB shifted out first when clock goes high
The DELAY normally consists of 2 NOP instructions. When the clock is too fast you can specify a delay time(in uS).
The clock pin is brought to a initial level before the shifts take place. For mode 0, it is made 1. This way, the first clock can go from 1 to 0. And back to 1. You could see this as another clock cycle. So check if you use the proper mode. Or put the clock pin in the right state before you use SHIFT.
|
E |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Sun May 13, 2018 5:12 pm Post subject: |
|
|
One further question.
Should the routine be writing all 3 (Low, High, Extended) Fuse Bits then the Lock Bits?
E |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun May 13, 2018 6:26 pm Post subject: |
|
|
Hi,
Shift out is working for Fuse Bits Read, Flash Read/Write/Verify, EEPROM read write it's only for Writing to the fuses it's not working.
For the Fuse bits Read/Write I'm using a much longer delay than for Flash Access. So I don't think the problem is with the Delay and I'm using the same Mode as the Flash so that can't be it either.
I'll have a look at Byval Byte to Word, but I don't think that it either as I'm seeing "ACA0 00DC" which is exactly what I'd expect.
EDIT: Tryed forcing the fuse bits to FF and I'm still seeing 0 grrrrrrr,
Code: | CPU Information
CPU Signature=001E9404
Lock bits=2F
Fuse bits=00
Fuse bits high=D8
Fuse bits extended=F9
Calibration Byte=56
Setting fuse bits ACA0 00FF
CPU Information
CPU Signature=001E9404
Lock bits=2F
Fuse bits=00
Fuse bits high=D8
Fuse bits extended=F9
Calibration Byte=56
| The search goes on.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun May 13, 2018 6:57 pm Post subject: |
|
|
Hi All,
Tried Setting the fuse bits with my ISP and changing them with my programmer. I'm still seeing 0.
Code: | CPU Information
CPU Signature=001E9404
Lock bits=2F
Fuse bits=DC
Fuse bits high=D8
Fuse bits extended=F9
Calibration Byte=56
Setting fuse bits ACA0 00FF
Entering programming mode
CPU Information
CPU Signature=001E9404
Lock bits=2F
Fuse bits=00
Fuse bits high=D8
Fuse bits extended=F9
Calibration Byte=56 |
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
laborratte
Joined: 27 Jul 2005 Posts: 299 Location: Berlin
|
Posted: Mon May 14, 2018 10:03 am Post subject: |
|
|
i.dobson wrote: |
Code: | Sub Set_fusebits(byval Value As Byte)
(...)
#if Write_fuses = 1
Shiftout Slave_mosi , Slave_sck , Spi_write_word , 1 , 16 , Spi_delay_long
Shiftout Slave_miso , Slave_sck , Spi_write_word1 , 1 , 16 , Spi_delay_long
#endif
(...)
End Sub |
Can someone see what I'm going wrong.
|
maybe you should try to shiftout the fuse data on Slave_mosi? |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Mon May 14, 2018 10:26 am Post subject: |
|
|
Hi laborratte
Wow thats it. How does the old saying go:
You can't see the wood for the trees. I've spent hours looking at the code and didn't notice that. I can't test it at the moment but I'm almost 100% sure thats the problem.
Regards and Thankyou
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
|
Back to top |
|
|
|