stm8s001j3 i/0 control problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-16 6:03 AM
I am having a communication problem with MAX485 ic. I am trying to change Ic receiving mode to transmit mode by using 'PB4' pin and i am using UART1 , SWIM pin as a Transmitter. in some controllers i am unable control pin in the middle working. I am giving both IC's supply is 5V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-16 7:00 AM
The presentation here is weak.
Show the HW side connectivity of the parts and paths involved.
Show the SW side implementation, initialization and logic of what's being done.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-16 9:46 PM
Thanks for the reply, please find the below connections between controller and 485 ic
please find below configurations and operations
#define Tx_Enable GPIO_WriteHigh(GPIOB, GPIO_PIN_4)
#define Rx_Enable GPIO_WriteLow(GPIOB, GPIO_PIN_4)
GPIO_Init(GPIOB, GPIO_PIN_4,
GPIO_MODE_OUT_PP_LOW_FAST);
int main( void )
{
GPIO_Init(GPIOB, GPIO_PIN_4,
GPIO_MODE_OUT_PP_LOW_FAST);
CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1, ENABLE);
UART1_Config();
Rx_Enable;
enableInterrupts();
Uart_Rx[4]=Meter_id;
len=5;
Send_485(len);
while(1)
{ }
}
void Send_485(uint8_t Length)
{
Tx_Enable;
Delay(1000);
for(int i=0;i<Length;i++)
{
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET)
{
}
UART1_SendData8(Uart_Rx[i]);
}
Delay(1000);
Rx_Enable;
}
static void UART1_Config(void)
{
/* EVAL COM (UART) configuration -----------------------------------------*/
/* USART configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- Odd parity
- Receive and transmit enabled
- UART Clock disabled
*/
//UART1_DeInit();
GPIO_DeInit(GPIOA);
GPIO_Init(GPIOA, GPIO_PIN_1, GPIO_MODE_IN_PU_NO_IT);
GPIO_Init(GPIOD, GPIO_PIN_1,
GPIO_MODE_OUT_OD_HIZ_FAST);
UART1_Init((uint32_t)9600, UART1_WORDLENGTH_8D,UART1_STOPBITS_1, UART1_PARITY_NO,
UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);
/* Enable the UART Receive interrupt: this interrupt is generated when the UART
receive data register is not empty */
UART1->BRR1 = 0x68;
UART1->CR2 = 0x2C;
/* Enable UART */
//UART1_Cmd(ENABLE);
/* Enable general interrupts */
// enableInterrupts();
}
