Is it possible to send an 8 or 16 MHz clock signal to one of the GPIO? I have a device that needs either its own oscillator connected to OSC1 and OSC2. Or it will accept a clock signal from an external clock into OSC1. My thought is that is a simpler solution than putting more components onto my board. I just don't know if it can be done or how.
If anyone can point me in a good direction I would appreciate it.
Thanks!
Sending a clock signal to GPIO from 32u4.
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- VelvetLounger
- Posts: 14
- Joined: Mon Jul 22, 2019 1:20 am
- mikeysklar
- Posts: 14194
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Sending a clock signal to GPIO from 32u4.
You should be able to use a timer to generate a 8MHz signal on your 32u4. Here is an example using timer4. 16MHz is not going to be an option with a 32u4 running at 8MHz.
https://electronics.stackexchange.com/q ... ing-timer4
https://electronics.stackexchange.com/q ... ing-timer4
Code: Select all
// reset timer4
OCR4C = 0;
OCR4D = 0;
TCCR4A = 0x00;
TCCR4B = 0x00;
TCCR4C = 0x00;
TCCR4D = 0x00;
TCNT4=0;
// Toggle OC4D on Compare Match | enable PWM
TCCR4C = _BV(COM4D0) | _BV(PWM4D);
// Clear Timer on Compare Match
TCCR4D = _BV(WGM41);
// set lock bit for sync update
TCCR4E = _BV(TLOCK4);
// Set compare value
OCR4C = CLOCKCYCLE*2;
OCR4D = CLOCKCYCLE;
// No prescaling
TCCR4B = _BV(CS10);
- sj_remington
- Posts: 1021
- Joined: Mon Jul 27, 2020 4:51 pm
Re: Sending a clock signal to GPIO from 32u4.
If the CKOUT fuse is programmed, the system clock (typically 16 MHz with Arduino) will appear on PORTC, pin 7.
- VelvetLounger
- Posts: 14
- Joined: Mon Jul 22, 2019 1:20 am
Re: Sending a clock signal to GPIO from 32u4.
Hi mikeysklar. I'm using the 5V Itsy Bitsy which runs at 16 MHz so maybe I can make it work. However according the the datasheet for the MCP2515 it can run with 4,8, or 16MHz. Thank you for the link and the code.mikeysklar wrote:You should be able to use a timer to generate a 8MHz signal on your 32u4. Here is an example using timer4. 16MHz is not going to be an option with a 32u4 running at 8MHz.
- VelvetLounger
- Posts: 14
- Joined: Mon Jul 22, 2019 1:20 am
Re: Sending a clock signal to GPIO from 32u4.
Hi sj_remington. I will look into setting the CKOUT fuse.sj_remington wrote:If the CKOUT fuse is programmed, the system clock (typically 16 MHz with Arduino) will appear on PORTC, pin 7.
Thank you very much
Please be positive and constructive with your questions and comments.