Debug and use SPI on ATtiny at same time

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi folks,

 

I'm currently developing on ATtiny84A and begin to find very difficult to continue without a proper debugger.

So I've bought the AVR JTAG ICE and make my research and find that if I want to enable debugging (debugWire mode) on that chip,

I would have to enable the fuse DWEN which one disable the SPI port (that I need for a peripheral).

 

My question is : Is there any solutions to debug my chip keeping the SPI port UP ?

 

Thank's in advance.

Mike

This topic has a solution.

IOT is the future of the présent ;)

Last Edited: Thu. Feb 3, 2022 - 09:34 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

No,   when AS7.0 enables debugWIRE for you,  it sets the DWEN fuse.   This makes the dW pin functional for programming AND debugging.

The USI pins are free from programming duty i.e. use them for SPI, I2C,  UART or whatever.

 

You just leave the Tiny84 in debugWIRE mode for the development cycle.

Just remember to restore ISP when you go on holiday or have finished the project.

 

It is always wise to use real-life pullup resistors on the /CS pins of all SPI devices.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

michael_dalian wrote:
enable the fuse DWEN which one disable the SPI port

Does it?

 

Doesn't it just disable ISP - not the entire SPI function?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tiny84 has no proper SPI, I2C or UART peripherals.   Just USI which works pretty well for implementing Slaves.

 

You can of course use USI as an SPI Master.   It is just a bit crap compared to a proper peripheral.

 

The USI pins are shared with ISP.   So any external SPI slaves must play cricket during ISP (or debugWIRE disabling).

Hence external pullups on /CS pins.

 

This is exactly the same as ISP programming on a Mega32 or 328P.   External SPI slaves must be inactive during ISP.   Hence the expense of buying resistors.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome!

michael_dalian wrote:
So I've bought the AVR JTAG ICE ...
fyi

debugWIRE via USB UART | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

michael_dalian wrote:
So I've bought the AVR JTAG ICE

I don't think that supports debugWIRE ?

 

EDIT

 

It's not listed on the Product Page, but the Quick Start Guide says it does

 

https://www.microchip.com/en-us/development-tool/ATJTAGICE2

 

https://ww1.microchip.com/downloads/en/DeviceDoc/doc2562.pdf

 

Mk II, that is.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Feb 2, 2022 - 09:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Maybe get familiar with this diagram (which I very nearly made into a t-shirt for Morten) before you dabble with DWEN yourself (this job is best left to Studio):

 

https://onlinedocs.microchip.com...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mraardvark wrote:
this job is best left to Studio

+1

 

And be sure to follow the prompts - you do need to power-cycle when it tells you to power-cycle.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
I don't think that supports debugWIRE ?

IIRC:

JTAGICE supported only JTAG & ISP

JTAGICE mkII added debugWIRE

JTAGICE mkII rev B added xmega PDI

JTAGICE3 added SWD and made it all faster (and 'corrected' the PDI pinout)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


A picture paints 1,000 words and there is probably 1,000 words in here too.

 

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly