LM3S 811 | GPIO 模拟SPI 读取外设寄存器的值出问题

[复制链接]
4407|2
 楼主| Adniok 发表于 2012-2-22 09:59 | 显示全部楼层 |阅读模式
  1. long g_temp;
  2. unsigned char Read(unsigned char address)
  3. {
  4.         unsigned char cmd = 0x05;
  5.         unsigned char data =  0;
  6.         unsigned i = 0;
  7.         long temp = 0x00;
  8.         for(i  = 0;i<8;i++)
  9.         {
  10.                 if( (cmd & 0x80) == 0x80 )
  11.                 {
  12.                         GPIOPinWrite(GPIO_PORTA_BASE ,  GPIO_PIN_5 , GPIO_PIN_5);
  13.                 }
  14.                 else
  15.                 {
  16.                         GPIOPinWrite(GPIO_PORTA_BASE ,  GPIO_PIN_5 , ~GPIO_PIN_5);
  17.                 }
  18.                 delay(1);
  19.                 GPIOPinWrite(GPIO_PORTA_BASE , GPIO_PIN_2 , ~GPIO_PIN_2);
  20.                 cmd = (cmd<<1);
  21.                 delay(1);
  22.                 GPIOPinWrite(GPIO_PORTA_BASE , GPIO_PIN_2 , GPIO_PIN_2);       
  23.         }
  24. //        delay(10);
  25.         for(i=0;i<8;i++)
  26.         {
  27.                 if( (address & 0x80) ==  0x80)
  28.                 {
  29.                         GPIOPinWrite(GPIO_PORTA_BASE ,  GPIO_PIN_5 ,GPIO_PIN_5);       
  30.                 }
  31.                 else
  32.                 {
  33.                          GPIOPinWrite(GPIO_PORTA_BASE ,  GPIO_PIN_5 , ~GPIO_PIN_5);
  34.                 }
  35.                 delay(1);
  36.                 GPIOPinWrite(GPIO_PORTA_BASE , GPIO_PIN_2 , ~GPIO_PIN_2 );
  37.                 address = (address<<1);
  38.                 delay(1);
  39.                 GPIOPinWrite(GPIO_PORTA_BASE , GPIO_PIN_2 , GPIO_PIN_2 );
  40.         }
  41. //        delay(10);
  42.         for(i=0;i<8;i++)
  43.         {
  44.                 data = (data << 1);

  45.                 //g_temp =  (GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_6));
  46.                 delay(1);
  47.                 GPIOPinWrite(GPIO_PORTA_BASE , GPIO_PIN_2 , ~GPIO_PIN_2 );
  48.                
  49.                 if(GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_6))
  50.                 {
  51.                         data  |= 0x01;
  52.                 }
  53.                 delay(1);
  54.                 GPIOPinWrite(GPIO_PORTA_BASE , GPIO_PIN_2 , GPIO_PIN_2 );
  55.         }
  56.         delay(1);
  57.         GPIOPinWrite(GPIO_PORTA_BASE , GPIO_PIN_3 , GPIO_PIN_3);
  58.         return         data;
  59. }
示波器上能测试出外设寄存器已经将相应的值给出,但是使用GPIOPinRead()怎么都不能读到值,只能读到一个默认的值(0x10, 使用的是GPIOA)
larrybird 发表于 2012-4-10 09:46 | 显示全部楼层
为什么不用TI提供的SSI呢?
iEye 发表于 2012-4-17 14:05 | 显示全部楼层
GPIO_PIN_6 有没有配置为输入,用的是PD6啊? GPIOPinTypeGPIOInput()
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

1

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部