打印

请高手帮忙看一段组包 代码,在那里出问题了?

[复制链接]
1328|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
fengxu0217|  楼主 | 2008-11-13 16:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
程序如下,问题见后面:
                                    UART_buf[0][1]=0x55;
                UART_buf[0][2]=0xAA;
                UART_buf[1][0]=0xD0;        //响应值
                UART_buf[1][1]=eeprom_read_byte(ID_ADR);    //定位器ID
                if(card_id_sum>=2)
                {    //PORTC|=0x02;
                    UART_buf[1][2]=(card_id_sum-2);            //身份卡总数
                }
                else
                {
                    UART_buf[1][2]=0;                        
                }                            
                send0_buf_pointer=&UART_buf[card_id_sum][0];//初始值[2][0]
                if((card_id_sum+new_card_id_sum)<101)
                {
                    card_id_sum+=new_card_id_sum;    
                    UART_buf[1][2]+=new_card_id_sum;                    
                    for(i=0;i<new_card_id_sum;i++) //将新卡放到uart缓冲区
                    {
                        *send0_buf_pointer=new_card_buf[0];        //卡号高位
                        send0_buf_pointer++;
                        *send0_buf_pointer=new_card_buf[1];        //卡号低位
                        send0_buf_pointer++;
                        *send0_buf_pointer=new_card_buf[2];        //相对时间位
                        send0_buf_pointer++;
                    }
                    new_card_id_sum=0;
                }
                old_card_id_sum=0;
                
                send0_length=(card_id_sum*3-1);        //UART_buf[0][0]没有发送
                Create_CRC_CCITT(&UART_buf[0][1],send0_length);
                send0_length++;                        
                UART_buf[card_id_sum][0]=CRC_CCITT_H;                
                UART_buf[card_id_sum][1]=CRC_CCITT_L;
                send0_buf_pointer=&UART_buf[0][2];
                PORTD&=0xF7;//将RS485置为发送状态
                NOP();NOP();NOP();
                UDR0=UART_buf[0][1];    //开始发送数据


在这段程序中,第二行已赋值UART_buf[0][2]=0xAA,但是到了倒数第4行(send0_buf_pointer=&UART_buf[0][2];)的时候,*send0_buf_pointer的值却不是0xAA了,请问问题出在那里呢?

非常感谢!

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

28

主题

70

帖子

0

粉丝