Pages: [1]   Go Down
Author Topic: Clock signal on a digital pin  (Read 1922 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone.
I recently came up with a post where we can connect a hacked nintendo wii's pixart camera to Arduino via I2C. In the post they suggested that the camera's CLK, need to be 18, 20-25 MHz for 5 volt uControllers.
http://www.stephenhobley.com/blog/2009/03/01/pixartwiimote-sensor-library-for-arduino/comment-page-1/#comments
A guy named Adam McDonald commented in the same post that he's been able to use the clock signal of 8MHz from his Pro mini of 3.3v I/O lines  to the pixart camera.
Now I need a method be explained to me in an easy manner of "getting an 8Mhz signal by setting the fuse bytes on the Arduino to output the clock signal on a digital pin" (I don't understand how to get that 8MHz signal).
For that you obviously don't need to know that what I'm going to do with that signal. Just assume I need it?
Can anybody help me here with some real solutions.
Thanks in advance
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5301
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to set bit 6 of "low_fuses".

The very easiest way to do this (IHMO) with the Arduino environment is to edit your boards.txt file (search for it in your arduino installation) and find the section for the board you're interested in.

It will look something like this:

Code:
pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
pro328.upload.protocol=arduino
pro328.upload.maximum_size=30720
pro328.upload.speed=57600
pro328.bootloader.low_fuses=0xFF
pro328.bootloader.high_fuses=0xDA
pro328.bootloader.extended_fuses=0x05
pro328.bootloader.path=atmega
pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
pro328.bootloader.unlock_bits=0x3F
pro328.bootloader.lock_bits=0x0F

pro328.build.mcu=atmega328p
pro328.build.f_cpu=8000000L
pro328.build.core=arduino
pro328.build.variant=standard

Make a copy of that section, change all the "pro328" to something like "pro328ck" and change "pro328ck.name" to something like "Arduino Pro Mini (3.3V, 8 MHz, CKOUT)" (That's what you see in the 'boards' menu).

Now you can edit the "pro328ck.low_fuses" entry to whatever value you want. If you select that entry in Tools->Board and do a "Burn bootloader" the fuses will be set. nb. You probably need to restart the Arduino IDE every time you edit that file.

The clock output bit is bit 6 of low_fuses, you need to set it to 0 without changing any other bits in low_fuses.

If you do it correctly the clock signal should appear on digital Pin 8.

« Last Edit: February 13, 2013, 11:34:34 am by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5301
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PS: This can't be done with a serial/FTDI cable. You'll need to set up some sort of ISP programmer.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1051
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Take a look at Nick Gammon's guide, for setting up a 8 Mhz timer on pin 9

http://www.gammon.com.au/forum/?id=11643
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5301
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Take a look at Nick Gammon's guide, for setting up a 8 Mhz timer on pin 9

http://www.gammon.com.au/forum/?id=11643

On an 8mHz Pro Mini you can only get a 4mHz signal with a timer output.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1051
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
On an 8mHz Pro Mini

Sorry I missed that, was thinking  16mHz
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26341
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You should be able to get 8 MHz on an 8MHz Promini:

9.9 Clock Output Buffer
The device can output the system clock on the CLKO pin. To enable the output, the CKOUT Fuse has to be programmed.
This mode is suitable when the chip clock is used to drive other circuits on the system. The clock also
will be output during reset, and the normal operation of I/O pin will be overridden when the fuse is programmed.
Any clock source, including the internal RC Oscillator, can be selected when the clock is output on CLKO. If the
System Clock Prescaler is used, it is the divided system clock that is output.

This is not using a Timer output, its the free-running 8 MHz clock.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks will try it out soon tomorrow
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5301
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should be able to get 8 MHz on an 8MHz Promini:

9.9 Clock Output Buffer
The device can output the system clock on the CLKO pin. To enable the output, the CKOUT Fuse has to be programmed.

Yep, that's what my post was all about - setting bit 6 of low_fuse.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It would also better if anybody can show me how to bootload an Arduino Pro mini 3.3 volt. Any tutorial link for promini 3.3V will do.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I came up with this here
http://arduino.cc/en/Tutorial/ArduinoISP

My questions:
1. Do I need to put a logic level converters between the wires as I'm going to bootload the Arduino Pro Mini 3.3v with my Arduino Uno(5V)?
2. Do I need to put a 10uf cap between Reset & GND & should the RESET line of the programmer ARDUINO UNO go to PIN 10 of my Pro mini & ground parallel?
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5301
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I came up with this here
http://arduino.cc/en/Tutorial/ArduinoISP

My questions:
1. Do I need to put a logic level converters between the wires as I'm going to bootload the Arduino Pro Mini 3.3v with my Arduino Uno(5V)?

The pins have protection diodes but the datasheet says the maximum voltage on an i/O pin is Vcc+0.5V so it's best to use them. it. A simple resistor divider will do for 5V->3.3V, for 3.3V->5V (ie. MISO) you don't need anything.

« Last Edit: February 14, 2013, 04:21:51 am by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It worked. I did used a tutorial on how to bootload a Arduino using other arduino. Used it to bootload my Arduino Pro mini 3.3v with modified clock ouput pin 8 & used the successful Pvision lib for the exp. Yanks a lot
Logged

Pages: [1]   Go Up
Jump to: