Hello there! I'm having an issue running the sci_echoback_cpu01 example from the ControlSuite repository. Here's the thing - the example is originally configured for a 9600 BAUD, but actually works at a 4800 BAUD instead. This got me thinking that the clocking was incorrect. As per the example code,
//
// SCIA at 9600 baud
// @LSPCLK = 50 MHz (200 MHz SYSCLK) HBAUD = 0x02 and LBAUD = 0x8B.
//
SciaRegs.SCIHBAUD.all =0x0002;
SciaRegs.SCILBAUD.all =0x008B;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
This is with manually setting the LSPCLKDIV to 4 (should be the default),
EALLOW; ClkCfgRegs.LOSPCP.bit.LSPCLKDIV = 4; EDIS;
And manually setting the cpu clock to XTAL as such (default for the program), using the API from usb_dev_serial
SysCtlClockSet(SYSCTL_OSCSRC_XTAL | SYSCTL_PLL_ENABLE | SYSCTL_IMULT(20) | SYSCTL_SYSDIV(1));
But as per the usb_dev_serial comments,
SysCtlClockSet(SYSCTL_OSCSRC_XTAL | SYSCTL_PLL_ENABLE | SYSCTL_IMULT(20) | SYSCTL_SYSDIV(2));
should generate a 50MHz clock.
So a few questions:
- What's my clock actually running at? I know the calculation for the clock speed should be XTALSPEED*(IMULT*FMULT)/SYSDIV. Is the calculation for the BAUD incorrect or is the CPU frequency incorrect?
- What is the XTAL frequency? The datasheet says it's between 10 and 20 MHz, but I can't find any indicator on how to change it and actually specify it.
- How do I set the CPU to 200MHz? If I change the CPU config as such, I get illegal interrupts,
SysCtlClockSet(SYSCTL_OSCSRC_XTAL | SYSCTL_PLL_ENABLE | SYSCTL_IMULT(40) | SYSCTL_SYSDIV(1));