dia_betu
Hi to all,

First of all, I want to thank Thiago Alves for your work.

Some time ago I bought an FX1N-10MT clone from China. On the pcb it is written "JL1N-10MT". This have stm32f103rct6 on board.
The first step was to discover the BOOT0 pin. I have marked in the picture below where this pin is located and  and I solder a jumper.

boot0.pngjumpper.jpg



I identified the inputs and outputs :
PA0 - I0.0 (X0)
PA1 - I0.1 (X1)
PC5 - I0.2 (X2)
PC6 - I0.3 (X3)
PC7 - I0.4 (X4)
PC4 - I0.5 (X5)

PD2 - Q0.0 (Y0)
PC8 - Q0.1 (Y1)
PB10 - Q0.2 (Y2)
PB11 - Q0.3 (Y3)
PB6 - RUN LED - QX0.4

I created the file fx1n-10.cpp in the directory "C:\Users\{youruser}\OpenPLC_Editor\editor\arduino\src\hal" which contains the above configurations.
Into hals.json file from "C:\Users\{youruser}\OpenPLC_Editor\editor\arduino\examples\Baremetal" I added at the end :

"FX1N-10MT / FX1N-10M": {
"platform": "STMicroelectronics:stm32:GenF1😋num=GENERIC_F103RCTX,upload_method=serialMethod",
"source": "fx1n-10.cpp"
}

OBS.1
The inputs is pullup from internal so need to change on fx1n-10.cpp file from "pinMode(pinMask_DIN[i], INPUT);" to "pinMode(pinMask_DIN[i], INPUT_PULLUP);".

OBS.2
The board don't have external quartz. So I had to set the internal oscillator. For this need to edit the variant_generic.cpp file from "C:\Users\{youruser}\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.4.0\variants\STM32F1xx\F103R(C-D-E)T".

I write this at end of the file :

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief System Clock Configuration
* @param None
* @retval None
*/
WEAK void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};

/* Initializes the CPU, AHB and APB busses clocks */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
/* Initializes the CPU, AHB and APB busses clocks */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_USB;
PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
Error_Handler();
}
}

#ifdef __cplusplus
}
#endif


After making these changes, OpenPLC runs in this clone. I have tested the digital inputs/outputs and Modbus and they work fine.

I hope this information helps other people.
Reply 1 0
Reply