with 16MHz ceramic resonator

Get help and show off your TV-B-Gone kit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jeonlab
 
Posts: 9
Joined: Thu Nov 10, 2011 11:34 pm

with 16MHz ceramic resonator

Post by jeonlab »

I have an ATtiny85-20PU and 16MHz ceramic resonators. So I wanted to modify the firmware v1.2 for this change. I looked at the firmware files and thought these variables should be changed.

1. in main.c,

Code: Select all

// This function delays the specified number of 10 microseconds
// it is 'hardcoded' and is calibrated by adjusting DELAY_CNT 
// in main.h Unless you are changing the crystal from 8mhz, dont
// mess with this.
void delay_ten_us(uint16_t us) {
  uint8_t timer;
  while (us != 0) {
    // for 8MHz we want to delay 80 cycles per 10 microseconds
    // this code is tweaked to give about that amount.
    for (timer=0; timer <= DELAY_CNT; timer++) {
      NOP;
      NOP;
    }
    NOP;
    us--;
  }
}
I thought DELAY_CNT, which is defined in main.h as 11 (for 10 microseconds +1 for count = 11), should be changed to 6 (5 microseconds +1).

2. in MAKEFILE,

Code: Select all

F_CPU = 8000000
is to be changed to

Code: Select all

F_CPU = 16000000
3. in MAKEFILE,

Code: Select all

burn-fuse:
	$(AVRDUDE) $(AVRDUDE_FLAGS) -B 250 -u -U lfuse:w:0xfd:m -U hfuse:w:0xdf:m
I looked up this setting from http://www.engbedded.com/fusecalc and found it is for External Crystal, 3-8MHz, 16K CK/14 CK + 65ms. So I recalculated with a setting, External Crystal, 8- MHz, 16K CK/14 CK + 65ms, and got,

Code: Select all

burn-fuse:
	$(AVRDUDE) $(AVRDUDE_FLAGS) -B 250 -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m
Only lfuse value has been changed from 0xdf to 0xff.

In WinAVR, I recompiled these files, but I got some errors (I will post what errors I got later) and couldn't make hex file. I was wondering if there wass anyone tried to use 16MHz (I searched this forum and found one post, but there was no answer) resonator and tell me if there is any other settings or values I need to change.

By the way, in main.c, line 69, in the description for the pins, it says,

Code: Select all

       pin 7   PB0 - visible LED, and also connects to programming circuitry
Isn't the pin 7 PB2?
PB0 is the pin 5, isn't it?

Thanks.

Jinseok

Locked
Please be positive and constructive with your questions and comments.

Return to “TV-B-Gone Kit”