Seem to be a lot of stuff not right....
1st, we are not sure you connection is correct or not, there have many cases, claimed to made right connection, at the end is the connection that cause the problem, that is the reason why we want to see connection. A single wrong connection that you thought is correct, but connected wrongly will do it
I do know why RW is connected, if you look at the code, it always LOW (0), why bother connecting it to an IO? Just connect it to GND.
Also I seldom see LCD initialize start with clearing the LCD. It should start with 0x38 which is to let LCD know what is the interface, 4-bit or 8-bit. For 0x38, it should be 8-bit. Overall the lcd initialize routine looks weird to me Yes, it might work, but I have never try it.