View previous topic :: View next topic |
Author |
Message |
lbcomms
Joined: 14 Oct 2005 Posts: 120
|
Posted: Sun Mar 10, 2019 4:20 pm Post subject: ATMega2560 issue |
|
|
Have been using Mega328's for a while, but got some Mega2560 boards to play with. Wrote a quick port toggle routine to test them - it just sets port B as all outputs then toggles them at a 2Hz rate. Port B was uses as it's easy to access from the 6 pin programming header.
The code uploads without error but does not work. The pins just sit at about 0.5V, so presumably it's a port config line or similar missing somewhere.
Mega328P code (works as expected):
Code: | $regfile = "m328pdef.dat"
$crystal = 16000000
$hwstack = 32
$swstack = 10
$framesize = 40
'config i/o direction
DdrB = &B11111111 'Port B = all outputs
DdrC = &B00000000 'Port C = all inputs
DdrD = &B00000000 'Port D = all inputs
'Start of continuous loop
Do
PortB = 0
Waitms 500
PortB = 255
Waitms 500
Loop |
Mega2560 code (uploads without error but does nothing):
Code: | $regfile = "m2560def.dat"
$crystal = 16000000
$hwstack = 32
$swstack = 10
$framesize = 40
'config i/o direction
DdrB = &B11111111 'Port B = all outputs
DdrC = &B00000000 'Port C = all inputs
DdrD = &B00000000 'Port D = all inputs
'Start of continuous loop
Do
PortB = 0
Waitms 500
PortB = 255
Waitms 500
Loop |
Can anyone tell us what I'm missing for the Mega2560? Thanks in advance to anyone that can help on this one.
(BASCOM-AVR version : 2.0.7.8 , Latest : 2.0.8.1 ) |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Mar 11, 2019 10:55 am Post subject: |
|
|
Hi
on arduino MEGA2560 (real one not a copy) it works for me
Bascom last version
test with picoscope
jp _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Mar 11, 2019 11:02 am Post subject: |
|
|
I add the map of Arduino M2560 _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Tue Mar 12, 2019 3:51 am Post subject: |
|
|
'
Is JTAG Fuse disabled?
E |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Tue Mar 12, 2019 10:26 am Post subject: |
|
|
you said
"Port B was uses as it's easy to access from the 6 pin programming header. "
This connector is used more for the fuse-bits and less for the program.
but on a board ATMEGA2560 (copy or not) you have a usb port to transfer the program
please read my tuto about arduino board
https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=12472
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
lbcomms
Joined: 14 Oct 2005 Posts: 120
|
Posted: Tue Mar 12, 2019 1:37 pm Post subject: |
|
|
Never used the USB port to transfer a program, we've always used the 6 pin header for programming (via a cheap eBay USBASP programmer, going to a different PC USB port).
We've only ever used the USB port on the Arduino boards such as the NANO to send data to a terminal program (with PRINT and DEBUG) running on the PC.
I believe the USB port is used in the Arduino environment to upload code, but we have never used the Arduino software.
We use the Arduino boards as they are cheap and easy to obtain, but all coding is done in Bascom, overwriting anything such as the Arduino bootloader that may be pre-programmed into the board.
According to the documentation that came with the 2560 boards, SCK of the programming header is B.1, MOSI is B.2, and MISO is B.3 - I'll dig up a schematic / datasheet and confirm that is the case. |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Tue Mar 12, 2019 4:25 pm Post subject: |
|
|
Yes, I understand.
But I never coded Uno Arduino, or other arduino cards (MEGA2560) with the arduino program. I just recommend to test the card (mainly with the copy) with the arduino program. I saw very bad copy!
Then I use Bascom and only Bascom
For your test I used a new M2560 and I tested your program directly, without any problem.
with the following Arduino programmer setting:
comm port is easy to find (see my tuto)
Also I think the stack parameters are very low in your program use the recommended
$regfile = "m2560def.dat"
$crystal = 1600000000
$hwstack = 40
$swstack = 16
$framesize = 32
And increased them as variables and sub/function increase
I use the 6-pin connector to change the fuses-bits for example to save the data in EEPROM, I do not want this data to be deleted each time it is reprogrammed. the fuse is not programmable by USB.
Please let us know if you have success
JP
I use W10 pro64 bit and last version of bascom _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Wed Mar 13, 2019 12:57 pm Post subject: |
|
|
(SS/PCINT0) PB0
(SCK/PCINT1) PB1
(MOSI/PCINT2) PB2
(MISO/PCINT3) PB3
(OC2A/PCINT4) PB4
(OC1A/PCINT5) PB5
(OC1B/PCINT6) PB6
(OC0A/OC1C/PCINT7) PB7 _________________ For technical reasons, the signature is on the back of this message. |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Sat Mar 16, 2019 2:43 pm Post subject: |
|
|
Hello, check in the fuse if the reset vector is in the address 0000 or bootloader that is the usual in the ardiono because they load the program with bootloader. When you upload through the ISP, step on the bootloader and when the program starts it jumps to the bootloader that is no longer in memory. It should be set to 0000 when you do not use the bootloader.
regards |
|
Back to top |
|
|
|