This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to point table(code)?

I write a program as following. I want to point a table for driving step motor to ccw or cw.
But I cant access code table data. Please help me. Thanx.

#include <reg52.h>

void main(void)
{

unsigned char code uc_code_SMCW_Table[8]={0x09,0x01,0x02,0x03,0x06,0x04,0x0c,0x08};

unsigned char code uc_code_SMCCW_Table[8]={0x08,0x0c,0x04,0x06,0x02,0x03,0x01,0x09};

unsigned char code *uc_code_SM_Table_Ptr;

unsigned char data uc_data_SM_Table_Index;

uc_data_SM_Table_Index=1;

switch(uc_data_SM_Table_Index) {

case 1:

uc_code_SM_Table_Ptr=uc_code_SMCW_Table;

break;

case 2:

uc_code_SM_Table_Ptr=uc_code_SMCCW_Table;

break;

}

//The result is not correct.

uc_data_SM_Table_Index=uc_code_SM_Table_Ptr[0];

}

Parents
  • Sorry I really explain clearly. My program set in Atmel AT89S52.

    The Xtal is 11.0592MHz. I use debug in every step.

    The First Step uc_data_Table_Index=1;

    The Second Step uc_data_SM_Table_Ptr point to uc_code_SMCW_Table.

    The Third Step I expect uc_data_SM_Table_Index=9; But In fact,

    uc_data_SM_Table_Index=1. I am very comfusion. Please help me.

    Thanx.

Reply
  • Sorry I really explain clearly. My program set in Atmel AT89S52.

    The Xtal is 11.0592MHz. I use debug in every step.

    The First Step uc_data_Table_Index=1;

    The Second Step uc_data_SM_Table_Ptr point to uc_code_SMCW_Table.

    The Third Step I expect uc_data_SM_Table_Index=9; But In fact,

    uc_data_SM_Table_Index=1. I am very comfusion. Please help me.

    Thanx.

Children