There are two check_button() functions being defined.
One is empty, just above 'void lcdcmd(unsigned int ch)'.
This may be the cause of the problem, however try using gdb to debug.
This is incorrect. This should be 4096. Although it says 1024 in the PCMCLK datasheet, it has been correctedSo DIVI = 177 and DIVF = 0.1541195011 * 1024 = 157.8183... I "rounded" it at 158.