Hi,
I'm trying to use DIVSCLK as a clock source to an external device. However, I'm not able to get an output signal from the pin and I'm not sure what I'm missing from the code. I would appreciate some feedback!
Thank you.
//This code is to output a clock signal from DIVSCLK
#include "msp.h"
volatile uint32_t msTicks; /* counts 1ms timeTicks */
/*----------------------------------------------------------------------------
SysTick_Handler
*----------------------------------------------------------------------------*/
void SysTick_Handler(void) {
msTicks++;
}
/*----------------------------------------------------------------------------
delays number of tick Systicks (happens every 1 ms)
*----------------------------------------------------------------------------*/
void delay (uint32_t dlyTicks) {
uint32_t curTicks;
curTicks = msTicks;
while ((msTicks - curTicks) < dlyTicks);
}
void initilize (void)
{
// Enable GPIO Port Q peripheral - OUTPUT
SYSCTL->RCGCGPIO |= SYSCTL_RCGCGPIO_R14;
//Registers for DIVSCLK
SYSCTL->DIVSCLK |= SYSCTL_DIVSCLK_DIV_M; //divisor value
SYSCTL->DIVSCLK |= SYSCTL_DIVSCLK_SRC_PIOSC; //clock source is PIOSC
SYSCTL->DIVSCLK |= SYSCTL_DIVSCLK_EN; // clock output is enabled
//GPIO Q: registered needed for an output at DIVSCLK (hopefully!)
GPIOQ->DR2R |= BIT4; // Set drive strength (2mA)
// Set pin type
GPIOQ->ODR |= (BIT4);
GPIOQ->PUR |= (BIT4);
GPIOQ->DEN |= BIT4; //set this bit
GPIOQ->DIR |= BIT4; //*direction is output
GPIOQ->AFSEL |= BIT4; //*need alternative function on this pin
GPIOQ->PCTL |= 0xF0000000; //PMC7: port mux control 7 to be able to use DIVSCLK
}
void Delay (uint32_t dlyTicks) {
uint32_t curTicks;
curTicks = msTicks;
while ((msTicks - curTicks) < dlyTicks);
}
int main(void)
{
SysTick_Config(SystemCoreClock / 1000); /* Systick interrupt each 1ms */
initilize();
while(1)
{
GPIOQ-> DATA |= BIT4;
}}