cancel
Showing results for 
Search instead for 
Did you mean: 

stm8s001j3 i/0 control problem

nraj
Associate II

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.

2 REPLIES 2

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks for the reply, please find the below connections between controller and 485 ic0693W00000WIcRJQA1.png 

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();

}