View previous topic :: View next topic |
Author |
Message |
scottsc
Joined: 02 Sep 2012 Posts: 7
|
Posted: Tue Nov 03, 2015 3:51 pm Post subject: Can not program Mega32 |
|
|
Acording to the datasheet the ATMega32C1 is shipped with 8MHz internal frequency generator enabled, but after compiling the program, I get the message:
"Could not detect chip. Auto Program failed"
Code: | $regfile = "m32can.dat" ' processor we use
$crystal = 8000000 |
I read in the forum that new chips are shipped with the clock "divide by 8" enabled, so I also tried:
Code: | $regfile = "m32can.dat" ' processor we use
$crystal = 1000000 |
Same result.
In the Bascom-AVR option I have selected "Use Hardware SPI"
I also tried Code: | $regfile = "m32can.dat" ' processor we use
Config Spi = Soft , Din = Portb.0 , Dout = Portb.1 , Ss = None , Clock = Portb.7 ' , Spiin = Value , Mode = Mode
'Tried this with $crystal = 8000000, and $crystal = 1000000 |
And again the same error
Any suggestions, what I am doing wrong....
scott
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Tue Nov 03, 2015 4:57 pm Post subject: Programmer? |
|
|
What programmer are you using?
Ben Zijlstra |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Tue Nov 03, 2015 9:25 pm Post subject: |
|
|
Datasheet says that programming speed can not exceed 1/4 microcontroller clock
So if Mega is shipped with 1MHz then
1MHz is 1million Hz /s
1000 000 / 4 = 250 000
250 000 = 250kHz
I dont know what "Auto" in programmer settings means but not detect slow chip
Please look at last two pictures at bottom of this page http://bart-projects.cba.pl/ckdiv8.html
Set speed to 187,5kHz and have fun |
|
Back to top |
|
|
scottsc
Joined: 02 Sep 2012 Posts: 7
|
Posted: Wed Nov 04, 2015 6:49 pm Post subject: |
|
|
I am using the AVRSPI MKII programmer.
Figured out what was wrong. I initially used MISO(PB0), MOSI(PB1), and CSK(PB7) and Reset(PE0) for the SPI programming as I shown in the data sheet.
Then I tried the alternate pin figuration MISO_A(PD2), MOSI_A(PD3), CSK_A(PD4) and Reset(PE0) for the SPI connection, and that works.
Is that normal to use the alternate pin figuration????
Thanks for the help
Scott |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Wed Nov 04, 2015 9:04 pm Post subject: |
|
|
are you sure about that?
- you really use the 90CAN32 ?
- according the PDF the connections must be PE0(PDI), PE1(PDO) and PB1(SCK)
often the AVR SPI is the same as the external programming SPI. But not always. For example M128 uses different pins for external programming and the SPI.
But like i said, the PDF shows an entire different table in the 'SPI Serial Programming overview' _________________ Mark |
|
Back to top |
|
|
scottsc
Joined: 02 Sep 2012 Posts: 7
|
Posted: Fri Nov 06, 2015 10:05 pm Post subject: |
|
|
No, I didn't use 90CAN32. Initially I tried to used 90CAN32 def file because the help file says that 90CAN32 is for all CAN devices.
Now I am using the m32M1 def file.
My question still stands. Why is the default for SPI programming on a new chip MISO_A(PD2), MOSI_A(PD3), CSK_A(PD4) and Reset(PE0), and not MISO(PB0), MOSI(PB1), and CSK(PB7)
Thanks,
Scott |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Sun Nov 08, 2015 10:08 pm Post subject: |
|
|
Hi Scott,
I think you can better ask Atmel why they did this.
Looking at the datasheet it has something to do (i think) with the PSCOUT (power stage controller) they share the same pin as the MOSI/MISO.
They talking in the datasheet about For external component safety reason, the state of PSC outputs during Reset can be programmed by fuses PSCRB, PSCARV & PSCBRV. I can image that this can conflict with the ISP.
Or that you during programming with the ISP set the "external component" in unknown or unwanted state.
In the datasheet is mentioned that you need to use PD2,3,4 for the ISP, but to be honest I could have make the same mistake. Only read this part of the datasheet when it's not working.
have fun,
Evert _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Nov 09, 2015 4:03 pm Post subject: |
|
|
Ok so you use M32M1. yes that is something to ask Atmel about. This info is in the PDF. (serial downloading)
But i ran into this problem with the M128 too long time ago _________________ Mark |
|
Back to top |
|
|
scottsc
Joined: 02 Sep 2012 Posts: 7
|
Posted: Sat Nov 14, 2015 2:23 pm Post subject: |
|
|
I have contacted Atmel. When I get an answer I will post it |
|
Back to top |
|
|
|