Hi All
Ive been trying to setup the PLLB on my sam4S explained board to increase the clock frequency to the maximum. For some reason i cannot make the GPIO pins toggle faster than 3MHz? If i set the CKGR_PLLBR_MULB bits past a point the GPIO's just stop toggling even if the frequency is below 100 MHz. Her is my code:
/* * ATSAM4S_BARE_1.c * * Created: 4/24/2020 2:54:59 PM * Author : Atticus */ #include "sam.h" //delay function void delay (void){ for (volatile uint16_t x=0; x<65535;x++){ asm ("nop"); } } void set_pin_toggle(void){ REG_CKGR_MOR |= (CKGR_MOR_KEY_PASSWD) | (CKGR_MOR_MOSCRCF_8_MHz); //enable the periferal clock for PIOC REG_PMC_PCER0 |= (PMC_PCDR0_PID13); //set the multiplyer and divider //Here i cannot go more than 6???? REG_CKGR_PLLBR |= CKGR_PLLBR_MULB(6) | CKGR_PLLBR_DIVB(1); //select PLLB as the master clock REG_PMC_MCKR |= PMC_MCKR_CSS_PLLB_CLK; //enable PIOC controller for pin 30 REG_PIOC_PER |= PIO_PER_P30; //set as output REG_PIOC_OER |= PIO_PER_P30; } int main(void) { /* Initialize the SAM system */ SystemInit(); set_pin_toggle(); while (1) { //Set Output Data Register REG_PIOC_SODR |= PIO_PER_P30; //clear Output Data Register REG_PIOC_CODR |= PIO_PER_P30; } }