STM/Modbus/Baremetal/UART_RS485_Modbus_Slave/Source/Modbus/Slave/Modbus_Slave.c
void MBPresetSingleRegister(unsigned int *InArr, unsigned int InArrSize)
{
	unsigned int StAddress = MBStartAddress();
	//exception code 03 cannot be done for function code 06
	//check of exception code 02
	if ((StAddress) <= (InArrSize - 1u))
	{
		*(InArr + StAddress) = (unsigned int) (data_in[4] << 8)
				| (unsigned int) (data_in[5]);	//MSB FIRST AND THEN LSB IS ORed
		ResponseFrameSize = CharCount;
	}
	else
		MBException(0x02);	//Exception code 02 = ILLEGAL DATA ADDRESS

	MBSendData(ResponseFrameSize);		//send response if not broadcast message
}
//*********Modbus Register Write Operations*************
//C function to Write Single Analog register (Function code 06)

Modbus Register Write Operations
C function to Write Single Analog register (Function code 06)
Modbus Register Write Operations C function to Write Single Analog register ( Function code 06 )
void MBPresetSingleRegister(unsigned int *InArr, unsigned int InArrSize)
{
	unsigned int StAddress = MBStartAddress();
	if ((StAddress) <= (InArrSize - 1u))
	{
		*(InArr + StAddress) = (unsigned int) (data_in[4] << 8)
				| (unsigned int) (data_in[5]);	
		ResponseFrameSize = CharCount;
	}
	else
		MBException(0x02);	
	MBSendData(ResponseFrameSize);		
}
void MBPresetSingleRegister ( unsigned int * InArr , unsigned int InArrSize ) { unsigned int StAddress = MBStartAddress ( ) ; if ( ( StAddress ) <= ( InArrSize - 1u ) ) { * ( InArr + StAddress ) = ( unsigned int ) ( data_in [ 4 ] << 8 ) | ( unsigned int ) ( data_in [ 5 ] ) ; ResponseFrameSize = CharCount ; } else MBException ( 0x02 ) ; MBSendData ( ResponseFrameSize ) ; }
Modbus Register Write Operations
C function to Write Single Analog register (Function code 06)
Modbus Register Write Operations C function to Write Single Analog register ( Function code 06 )
//exception code 03 cannot be done for function code 06
 //check of exception code 02
 //MSB FIRST AND THEN LSB IS ORed
 //Exception code 02 = ILLEGAL DATA ADDRESS
 //send response if not broadcast message
