The global renewable energy portfolio is experiencing a growing proportion of shipboard photovoltaic (PV) energy. Grid-connected system has become the development trend of photovoltaic power generation technology in marine applications because of its high energy utilization efficiency. However, in the grid-connected process, harmonic pollution is easily caused by time-varying marine environment disturbance, which affects the quality of grid-connected power. The current recurrent neural network Levenberg-Marquardt backpropagation (CRNN-LM-BP) method, a control methodology, is introduced in this paper to ensure the robustness, stability, and consistency of the system. In addition, the inductance-capacitance-inductance (LCL) filter is optimized using particle swarm optimization (PSO) to minimize the presence of high frequency harmonics. The system that has been developed possesses the ability to improve the accuracy of steady-state control, operate with high efficiency and effectiveness, and maintain a total harmonic distortion of 1.73 %. Concurrently, streamlining the Jacobian matrix in the LM algorithm expedites convergence. It enables the system to improve its dynamic response, minimize excess, and quickly return to a stable condition when faced with load variations, a wide range of filter parameter adjustments, and voltage fluctuations. The suggested method’s effectiveness and applicability are evaluated by comparing it to the traditional proportional-resonant control, CRNN-BP control, using Matlab/Simulink and the real-time simulator OPAL-RT5700..