2010-10-06 06:35 AM
hi
i was tring to activate USART3 On Port C PC10,PC11. i used this configuration : USART3->CR1 = 0x0C; //Receiver enable, Transmitter enable, USART disable USART3->CR2 = 0x0; USART3->BRR=156;//9600 at 24Mhz setsystemclock(); //set system clock to 24Mhz AFIO->MAPR|=0x10;//port remap as uart //PC10 TX PC11 RX GPIOC->CRH=0x4B00; //PC11 in input floating mode for RX. PC10 Alternative Output TX. RCC->APB2ENR |=0x40000; USART3->CR1 |=2000; //Uart Enable; while(1) { while(TxCounter < 30) { /* Send one byte from USARTy to USARTz */ USART3->DR =( TxBuffer[TxCounter] & (uint16_t)0x01FF); while(((USART3->SR)&0x40)>0);//wait transmition complete TxCounter++; /* Loop until USARTy DR register is empty */ } TxCounter=0; //GPIOC->ODR=0x3ffff; //GPIOC->ODR=0x0; } but for some reason it does not work?? can you help? thanks.2010-10-10 06:37 AM
i determine the value without assuming the inital value.right?
Correct, but now imagine you don't have a monolithic application, but one where different routines initialize different pieces of hardware and don't make assumptions about what other hardware has already been enabled, but simply enable the hardware they need. For example USART1 and GPIOA.
2010-10-11 12:06 AM
2010-10-11 07:46 AM
how did you get to the number 0x9c4?
24,000,000 / 9,600 = 2,500 = 0x9C4 This uses the fact that while the USART is using a 1/16th clock it also represents the baud rate divider with a 4-bit fixed point fractional component.2010-10-22 01:08 AM
I also had problems getting USART2 working. I followed the guidance on this thread and solved the problem but cant help feel I am missing some documentation where it implicitly says to enable the clocks first? I`m new to ARM processors but not to programming
2010-10-22 01:36 AM
From ''RM0041 Reference Manual'' for stm32f100xx, last paragraph in section 2.1:
After each device reset, all peripheral clocks are disabled (except for the SRAM and FLITF).Before using a peripheral you have to enable its clock in the RCC_AHBENR,
RCC_APB2ENR or RCC_APB1ENR register.
2010-10-22 05:47 AM
I also had problems getting USART2 working. I followed the guidance on this thread and solved the problem but cant help feel I am missing some documentation where it implicitly says to enable the clocks first? I`m new to ARM processors but not to programming
It is a synchronous part, unless the parts are clocked they are non-functional and non-responsive. CMOS parts draw the majority of their current when signals transition, if you turn off clocks it will consume less power, unused peripherals are turned off to save power.