Page 1 of 1

ST_HAL is not working in CHIBI_OS

Posted: Sun Oct 02, 2016 6:59 am
by ep.hobbyiest
Hi,

I m using STM32F303xx. I configured STM_HAL for UART and it is working indepedent. But if ported same in chibi os then initilization is gettting complete, but uart is not sending any data to pc.

i checked many times but the result is same.

Re: ST_HAL is not working in CHIBI_OS

Posted: Sun Oct 02, 2016 7:51 am
by Giovanni
I would look into differences in IRQ vector names.

No enough info for any other meaningful suggestion.

Giovanni

Re: ST_HAL is not working in CHIBI_OS

Posted: Sun Oct 02, 2016 8:58 am
by ep.hobbyiest
Following is code i was trying in. I didn't used interrupt fot that.

Code: Select all

void MX_USART1_UART_Init(void)
{

  palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7));       /* USART1 TX.       */
  palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));      /* USART1 RX.       */

  RCC->APB2ENR |= 0x00002000;
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 19200;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  huart1.Init.OneBitSampling = UART_ONEBIT_SAMPLING_DISABLED ;
  huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
  HAL_UART_Init(&huart1);
  HAL_UART_Transmit(&huart1,"Hello",5,1000);
}


I didn't change any IRQ vector address or other thing.

mcuconf.h

Code: Select all

#define STM32_UART_USE_USART1               FALSE
#define STM32_UART_USE_USART2               FALSE
#define STM32_UART_USE_USART3               FALSE

Re: ST_HAL is not working in CHIBI_OS

Posted: Sun Oct 02, 2016 9:02 am
by Giovanni
I would check how the baud rate is calculated.

You are mixing HAL and ST HAL, that scenario is not supported, you should make a choice or be ready to address the possible issues.

Giovanni

Re: ST_HAL is not working in CHIBI_OS

Posted: Sun Oct 02, 2016 9:26 am
by ep.hobbyiest
Hi,

i was comfortable with STM HAL. So, i chose that.

following is the method , how baud rate is calculated.

baudrate = 19200;

Code: Select all

//huart->Instance->BRR = clock / bau_rate;
huart->Instance->BRR = (uint16_t)(__DIV_SAMPLING16(HAL_RCC_GetPCLK2Freq(), huart->Init.BaudRate));


are PCLK2 and APB2 same?
if yes, then it is 36Mhz.

Re: ST_HAL is not working in CHIBI_OS

Posted: Sun Oct 02, 2016 11:46 am
by Giovanni
PCLK2 and APB2 are the same.

Giovanni

Re: ST_HAL is not working in CHIBI_OS

Posted: Mon Oct 03, 2016 5:50 am
by Chudik
ep.hobbyiest
Unfortunately Chibi HAL does not work with ST_HAL.
And I doubt Giovanni would do anything about that until STM come to him and pay for such work. That would be my dream :)

Re: ST_HAL is not working in CHIBI_OS

Posted: Thu Oct 06, 2016 3:33 am
by ep.hobbyiest
Hi,
Following is the what i tried but unfortunately same result.
Now i am trying with configuring register without STM_HAL.
So this time also not working. I am configuring USART register then also it is showing unchanged in register window.

here is my configuration.

Code: Select all

#define PCLK2_FREQ  36000000
#define BAUD_RATE   19200

#define  USART_CR1_RE                        ((uint32_t)0x00000004)            /*!< Receiver Enable */
#define  USART_CR1_TE                        ((uint32_t)0x00000008)            /*!< Transmitter Enable */
#define UART_OVERSAMPLING_16                    ((uint32_t)0x0000)
#define UART_PARITY_NONE                    ((uint32_t)0x0000)
#define UART_WORDLENGTH_8B                  ((uint32_t)0x00000000)
#define  USART_CR1_UE                        ((uint32_t)0x00000001)            /*!< USART Enable */

#define UART_MODE_TX_RX                     ((uint32_t)(USART_CR1_TE |USART_CR1_RE))

void init(void)
{
  palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7));       /* USART1 TX.       */
  palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));      /* USART1 RX.       */
//  utils_sys_lock_cnt();
  RCC->APB2ENR |= 0x00002000;

  USART1->CR1 = (UART_WORDLENGTH_8B | UART_PARITY_NONE | UART_MODE_TX_RX | UART_OVERSAMPLING_16);
  USART1->CR2 = UART_STOPBITS_1;
  USART1->CR3 = (UART_HWCONTROL_NONE | UART_ONEBIT_SAMPLING_DISABLED);
  USART1->BRR = PCLK2_FREQ/BAUD_RATE;
  USART1->CR1 |= (USART_CR1_UE | 0x00000020);
}


here is attached snapshot.

Image