DC motor with encoder in renesas synergy S5D5

Hi,

i have used the external irq driver to read the encoder count callback function code as given below for your reference. kindly help to short the issues 

void g_external_irq2_callback(external_irq_callback_args_t *p_args)

{

if(p_args->channel==2)

{

if(count_test==1)

{

count22++;

else if(count_test==2)

{

count22--;

}

how to interface the rotary encoder in S5D5 synergy?.