RCC_CRbits.HSEON=1;
RCC_CRbits.HSION=0;
RCC_CRbits.PLLON=1;
RCC_CFGRbits.MCO=7;//MCO: Microcontroller clock output 111: PLL clock divided by 2 selected
RCC_CFGRbits.OTGFSPRE=0;//Bit 22 USBPRE: USB prescaler 0: PLL clock is divided by 1.5 72/1.5=48
RCC_CFGRbits.PLLMUL=7;//8*9=72 Bits 21:18 PLLMUL: PLL multiplication factor 0111: PLL input clock x 9
RCC_CFGRbits.PLLXTPRE=0;//Bit 17 PLLXTPRE: HSE divider for PLL entry 0: HSE clock not divided
RCC_CFGRbits.PLLSRC=1;//Bit 16 PLLSRC: PLL entry clock source 1: HSE oscillator clock selected as PLL input clock
RCC_CFGRbits.ADCPRE=3;// 36/8 Bits 15:14 ADCPRE: ADC prescaler 11: PCLK2 divided by 8
RCC_CFGRbits.PPRE2=4;// 72/2=36 //Bits 13:11 PPRE2: APB high-speed prescaler (APB2) 100: HCLK divided by 2
RCC_CFGRbits.PPRE1=5;//72/4=18 Bits 10:8 PPRE1: APB low-speed prescaler (APB1) APB low-speed clock(PCLK1). 101: HCLK divided by 4
RCC_CFGRbits.HPRE=0;//72M Bits 7:4 HPRE: AHB prescaler 0xxx: SYSCLK not divided
RCC_CFGRbits.SW=2;//Bits 1:0 SW: System clock switch 10: PLL selected as system clock
UART2_Init(9600);
I use the stm32f103ze mcu in 8MHz is ok.
and I want to config to 72MHz, but I can not use the uart write bytes correct.
How can I use 72MHz throuth PLL
- filip.grujcic
- Posts: 822
- Joined: 14 May 2018 08:34
Re: How can I use 72MHz throuth PLL
Hello,
In mikroC PRO for ARM, clock settings are configured in the Edit Project window (Ctrl + Shift + E).
Open it, click on the Load scheme button and load the configuration scheme from the attachment.
You can then remove the all the lines from your code for configuring these registers, as they will overwrite the ones you set in Edit Project.
Recompile your project.
Regards,
In mikroC PRO for ARM, clock settings are configured in the Edit Project window (Ctrl + Shift + E).
Open it, click on the Load scheme button and load the configuration scheme from the attachment.
You can then remove the all the lines from your code for configuring these registers, as they will overwrite the ones you set in Edit Project.
Recompile your project.
Regards,
- Attachments
-
- STM32F103ZE_HSE_8_to_72MHz_PLL.zip
- (824 Bytes) Downloaded 58 times
Filip Grujcic
Re: How can I use 72MHz throuth PLL
thanks for your help.
That's ok for my project.
I cal that APB1 clock is 72/2=36MHz
and I use CANculator to create code as below:
/*Place/Copy this part in declaration section*/
const unsigned int SJW = 1;
const unsigned int BRP = 4;
const unsigned int PHSEG1 = 7;
const unsigned int PHSEG2 = 2;
const unsigned int PROPSEG = 8;
const unsigned int CAN_CONFIG_FLAGS =
_CAN_CONFIG_AUTOMATIC_RETRANSMISSION &
_CAN_CONFIG_RX_FIFO_NOT_LOCKED_ON_OVERRUN &
_CAN_CONFIG_TIME_TRIGGERED_MODE_DISABLED &
_CAN_CONFIG_TX_FIFO_PRIORITY_BY_IDINTIFIER &
_CAN_CONFIG_WAKE_UP;
/*Place/Copy this part in init section*/
CAN1InitializeAdvanced(SJW, BRP, PHSEG1, PHSEG2, PROPSEG, CAN_CONFIG_FLAGS, &_GPIO_MODULE_CAN1_PD01);
I use portb8,b9 as CAN PORT
SO, I CHANGE THE CODE TO FOLLOW:
CAN1InitializeAdvanced(SJW, BRP, PHSEG1, PHSEG2, PROPSEG, CAN_CONFIG_FLAGS, &_GPIO_MODULE_CAN1_PB89);
AND I USE
CAN1Write(ID_2nd, RxTx_Data, 1, Can_Send_Flags);
TO SEND DATA TO CANBUS
AND I USE THE CANCARD RECEIVE THE CAN DATA FROM THE MCU, BUT I CANNOT RECEIVE ANYTHING.
CAN U HELP ME TO SOLVE THE QUESTION?
That's ok for my project.
I cal that APB1 clock is 72/2=36MHz
and I use CANculator to create code as below:
/*Place/Copy this part in declaration section*/
const unsigned int SJW = 1;
const unsigned int BRP = 4;
const unsigned int PHSEG1 = 7;
const unsigned int PHSEG2 = 2;
const unsigned int PROPSEG = 8;
const unsigned int CAN_CONFIG_FLAGS =
_CAN_CONFIG_AUTOMATIC_RETRANSMISSION &
_CAN_CONFIG_RX_FIFO_NOT_LOCKED_ON_OVERRUN &
_CAN_CONFIG_TIME_TRIGGERED_MODE_DISABLED &
_CAN_CONFIG_TX_FIFO_PRIORITY_BY_IDINTIFIER &
_CAN_CONFIG_WAKE_UP;
/*Place/Copy this part in init section*/
CAN1InitializeAdvanced(SJW, BRP, PHSEG1, PHSEG2, PROPSEG, CAN_CONFIG_FLAGS, &_GPIO_MODULE_CAN1_PD01);
I use portb8,b9 as CAN PORT
SO, I CHANGE THE CODE TO FOLLOW:
CAN1InitializeAdvanced(SJW, BRP, PHSEG1, PHSEG2, PROPSEG, CAN_CONFIG_FLAGS, &_GPIO_MODULE_CAN1_PB89);
AND I USE
CAN1Write(ID_2nd, RxTx_Data, 1, Can_Send_Flags);
TO SEND DATA TO CANBUS
AND I USE THE CANCARD RECEIVE THE CAN DATA FROM THE MCU, BUT I CANNOT RECEIVE ANYTHING.
CAN U HELP ME TO SOLVE THE QUESTION?