can't connect mikroBootloader to XMEGA 128A1 board

Author
Message
User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: can't connect mikroBootloader to XMEGA 128A1 board

#16 Post by filip » 12 Oct 2022 09:59

Hi,

Can you use plain wire jumpers to connect the XMEGA board programmer connector and the CODEGRIP Connector ?

Regards,
Filip.

mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

Re: can't connect mikroBootloader to XMEGA 128A1 board

#17 Post by mikroSeven » 17 Oct 2022 11:22

Hi, Filip, tnx for answer.


Sorry, I don't understand what you mean.

Played around some more with the ATXMega128a1 board and the codeGrip but didn't things get to work.

I placed the ATXMega128a1 aside and took an ATMEGA2560 and connected ( I made an adapter) via 6 pin header to the codeGrip ADAPT.
ISP 2560 b.jpg
ISP 2560 b.jpg (26.27 KiB) Viewed 1946 times


Managed to write a .hex into the 2560 by CODEGRIP Suite 'protocol: ISP'.
250kHz works, 500kHz doesn't. ( no problem)

Next thing I'm gonna do ( with the 2560 ) is using the JTAG option in CODEGRIP Suite 'protocol'.
Firts make an adapter and try 2560 and JTAG.

To be continued.
To DIY or not to DIY

mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

Re: can't connect mikroBootloader to XMEGA 128A1 board

#18 Post by mikroSeven » 17 Oct 2022 12:41

YES! :D

Got my ATXmega128a1 programmed by 'protocol: PDI and by 500kHz ).

My DIY adapter for the ATmega2560, was also suitable for the ATXmega128a1 board.

Now the real work kan begin: CODING my ATXmega128a1's!

Thanks for your time, Filip!


Kind regards from the Netherlands! Marcel
To DIY or not to DIY

mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

Re: can't connect mikroBootloader to XMEGA 128A1 board

#19 Post by mikroSeven » 17 Oct 2022 12:55

Something wrong!

I coded this:
blinky 1.jpg
blinky 1.jpg (35.48 KiB) Viewed 1944 times



Doc shows 8MHz:
128.jpg
128.jpg (86.26 KiB) Viewed 1944 times




Scope should show prox 100Hz, but shows 50Hz.
scope 01.jpg
scope 01.jpg (147.72 KiB) Viewed 1944 times

I also checked the pcb itself, and it shows an 8MHz cristal.


To be continued...
To DIY or not to DIY

mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

Re: can't connect mikroBootloader to XMEGA 128A1 board

#20 Post by mikroSeven » 17 Oct 2022 16:34

Did put the ATXmega128a1 aside and took 2 ATmega2560's.

One I programmed ( as always before ) by USB, the other by the codegrip.
Did use exactly the same hex-file.

Now the 2560 programmed by the codegrip is off, too as by the ATXmega128a1.
The usb one is ok, shows 100Hz ( as always before )

Here in a picture:
twin 2560 1 b.jpg
twin 2560 1 b.jpg (118.62 KiB) Viewed 1941 times
The 'yellow one' is way off.


Kind regards!
To DIY or not to DIY

mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

Re: can't connect mikroBootloader to XMEGA 128A1 board

#21 Post by mikroSeven » 18 Oct 2022 16:20

Can I set fuse-bits to create the desired clockspeed?
To DIY or not to DIY

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: can't connect mikroBootloader to XMEGA 128A1 board

#22 Post by filip » 19 Oct 2022 10:52

Hi,

If I understand correctly, the clock is not set properly in regards to the parameters given in the project ?

Regards,
Filip.

mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

Re: can't connect mikroBootloader to XMEGA 128A1 board

#23 Post by mikroSeven » 19 Oct 2022 13:56

Hi, Filip.

Yes, the clock is wrong by a factor 8 or 16 ( 2^n )

When I'm right, the initial clock of the atxmega128a1 is 2MHz.
An should be able to set at 8Mhz or 32Mhz.




Gonna do/check the same with 2 ATmega328P boards, as I did with 2 atmega2560.

Kind regards!
To DIY or not to DIY

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: can't connect mikroBootloader to XMEGA 128A1 board

#24 Post by filip » 19 Oct 2022 14:26

Hi,

To set the clock to 32MHz, use the following code:

Code: Select all

  OSC_CTRL := 0x02;
  
  while RC32MRDY_bit = 0 do nop;
  
  CPU_CCP := 0xD8;
  CLK_CTRL := 1;
Regards,
Filip.

mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

Re: can't connect mikroBootloader to XMEGA 128A1 board

#25 Post by mikroSeven » 19 Oct 2022 15:19

Thanks a lot, Filip!
32MHz.jpg
32MHz.jpg (157.39 KiB) Viewed 1914 times

And I think, your code-example will give me enough courage to handle the clock speed of other processors!


Kind regards!
To DIY or not to DIY

mikroSeven
Posts: 161
Joined: 14 Mar 2016 10:24
Contact:

Re: can't connect mikroBootloader to XMEGA 128A1 board

#26 Post by mikroSeven » 30 Oct 2022 19:00

Hi,

started trying to get my ATMEGA2560 at right clockfrequence as well.
The clock is set at 16MHz in projectsettings in mikroPascal for AVR.

The code is just a square-wave at 10kHz.
Writing the .hex via xloader gives a 10kHz on oscilloscope.
Writng the .hex via codeGrip gives 620 Hz. Thats off in a factor 16 ( 10k / 620 ).

What I did so far:
I consulted the 2560-datasheet and Iadded at the very beging of my code:
CLKPR:= %10000000; // = CLKPR.7 is CLKPCE-bit
CLKPR:= %00000000;

Now I get 5KHz, still factor 2 off.

Here shown:

Code: Select all

program clock2560;

begin

{
  ORIGINAL CODE:
  while true do
    begin
      portL:= 255;
      delay_us(50);
      portL:= 0;
      delay_us(50);
    end;

  programming via USB      gives prox  10 kHz,   is OK!
  programming via codeGrip gives prox 620  Hz,  NOT ok!
  factor-off = 10k / 620 = 16
}

// adding following 2 lines
  CLKPR:= %10000000;             //  = CLKPR.7 is CLKPCE-bit
  CLKPR:= %00000000;
{  gives 5kHz

  tested some more:
    %00000001 gives 2500 Hz
    %00000010 gives 1250 Hz
    %00000011 gives  620 Hz
    %00000100 gives  310 Hz
}

  DDRL:= 255;     // portL as output

while true do
  begin
    portL:= 255;
    delay_us(50);
    portL:= 0;
    delay_us(50);
  end;

end.
 

Also played the CAL7-bit in OSCCAL-register but that was a misassumption!

I hope somebody can help me.

Tnx in advance, kind regards. Marcel
To DIY or not to DIY

Post Reply

Return to “mikroBootloader”