Pages: [1]   Go Down
Author Topic: Programmable Clock Output Programming (Arduino Due)  (Read 788 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to generate a clock output (pulse) on the CANRX pin of the Due but no luck.
Here is my code:
Code:
pmc_set_writeprotect(false);
        pmc_switch_pck_to_mainck(0,4);
        pmc_enable_pck(PIO_PA1B_PCK0);       
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This sets the CANRX pin to output ~500Hz, you can use a piezo speaker to check if it is working.
Code:
  pmc_switch_pck_to_sclk(PMC_PCK_0,PMC_PCK_PRES_CLK_64);
  pmc_enable_pck(PMC_PCK_0);   
  PIO_SetPeripheral(PIOA, PIO_PERIPH_B, PIO_PA1B_PCK0);

Once you have it working you can change the first line to the right clock and divider you need.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! I can get the right frequency but the signal does not seem to be a clean square wave. Do you know how to fix that?
Logged

Pages: [1]   Go Up
Jump to: