unreflected SYSAHBCLKCTRL register

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

unreflected SYSAHBCLKCTRL register

1,824件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Tue May 22 23:29:27 MST 2012
Hello,
Now I'm in trouble with a strange register setting behavior of LPC1343.
I set 6 bit of the SYSAHBCLKCTRL register of LPC1343 to use GPIO like this.
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);

But some of ports couldn't toggle as quite normal GPIO.
In particular, P1.0, P1.1, P2.0, P0.11, P1.2.
So I checked set register value (LPC_SYSCON->SYSAHBCLKCTRL) by debugger and I found a quite strange behavior.
6 bit of the  SYSAHBCLKCTRL was clear and even I put writing code (set 6 bit) in a loop forcibly but the same.
Watched register value (lower byte of 32bits) was 0b10111111 in sum all 7 bits was set except 6 bit.
Then I tried to stop to feed clock to A/D function for sharing pins like this.

LPC_SYSCON->PDAWAKECFG |= (1<<4);
LPC_SYSCON->PDRUNCFG |= (1<<4);

But these 5 GPIOs didn't work meanwhile other some GPIOs work.
How could I toggle these GPIOs or are there any means to set??

Thanks,
0 件の賞賛
返信
8 返答(返信)

1,654件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Mon May 28 06:10:45 MST 2012
Thanks a lot,
It worked.
I've just forgotten that registers that indicated with IOCON_R_ are not GPIO as default.
By setting to bit 1 on the LPC_IOCON it began to toggle.
Thanks,
0 件の賞賛
返信

1,654件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon May 28 04:05:09 MST 2012

Quote:
... I came to have a conclusion that ...

Please don't post such nonsense. You are confusing beginners with this statements :eek:

Since you refuse to post a project I can't help you to find your error

Meanwhile my 1343 is working as expected. This few lines included in a new LPCXpresso project are slow toggling this outputs (so that even LED's can show that your conclusion is wrong)

/*
===============================================================================
 Name        : main.c
 Author      : Zero
 Version     : 0.0
 Copyright   : no Copyright
 Description : slow toggling P1.0,P1.1,P0.11,P1.2
===============================================================================
*/

#ifdef __USE_CMSIS
#include "LPC13xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>

__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

int main(void)
{
 volatile static int i = 0,state=0;
 LPC_IOCON->R_PIO1_0 &=~0x07;        //reset function bit
 LPC_IOCON->R_PIO1_0 |= 0x01;        //set GPIO
 LPC_GPIO1->DIR         |= (1<<0);        //output
 LPC_IOCON->R_PIO1_1 &=~0x07;        //reset function bit
 LPC_IOCON->R_PIO1_1 |= 0x01;        //set GPIO
 LPC_GPIO1->DIR         |= (1<<1);        //output
 LPC_IOCON->R_PIO1_2 &=~0x07;        //reset function bit
 LPC_IOCON->R_PIO1_2 |= 0x01;        //set GPIO
 LPC_GPIO1->DIR         |= (1<<2);        //output
 LPC_IOCON->R_PIO0_11&=~0x07;        //reset function bit
 LPC_IOCON->R_PIO0_11|= 0x01;        //set GPIO
 LPC_GPIO0->DIR         |= (1<<11);    //output


 while(1)
 {
  i++ ;                    //inc counter
  if(i >200000)            //delay
  {
   i=0;                    //reset counter
   switch(state)        //switch outputs
   {
    case(0):LPC_GPIO1->DATA ^= (1<<0);    //toggle
            break;
    case(1):LPC_GPIO1->DATA ^= (1<<1);    //toggle
            break;
    case(2):LPC_GPIO1->DATA ^= (1<<2);    //toggle
            break;
    case(3):LPC_GPIO0->DATA ^= (1<<11);    //toggle
            break;
    default:break;
   }                    //end switch outputs
   state++;                //inc status
   if(state >3)state =0;//reset status
  }                        //end delay
 }
 return 0 ;
}
0 件の賞賛
返信

1,654件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Mon May 28 03:56:46 MST 2012
Well, as you explicitly set these lines to be assigned to debug interface, not to GPIO, the microcontroller did precisely what you ordered it to do. Read the IOCON registers description, set the lines as GPIO and do whatever you want to do.
0 件の賞賛
返信

1,654件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Mon May 28 03:14:32 MST 2012
Hello,

At least now I came to have a conclusion that P1.0, P1.1, P0.11, P1.2 of the LPC1343 doesn't work as GPIO.
Firstly I thought if I stop A/D clock feed they would work since these all 4 ports share A/D function.
But the result was different.
Though other all ports that share A/D worked properly but these 4 ports.
I write my code for reference.

    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16);
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<0);
    LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<12);
    LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<13);
    LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<14);

    GPIOSetDir( PORT1, 0, 1 );
    LPC_IOCON->R_PIO1_0 &= ~0x7;
    GPIOSetDir( PORT1, 1, 1 );
    LPC_IOCON->R_PIO1_1 &= ~0x7;
    GPIOSetDir( PORT0, 11, 1 );
    LPC_IOCON->R_PIO0_11 &= ~0x7;
    GPIOSetDir( PORT1, 2, 1 );
    LPC_IOCON->R_PIO1_2 &= ~0x7;

while(1)
{
    GPIOSetValue(PORT1, 0, 0);
    GPIOSetValue(PORT1, 1, 0);
    GPIOSetValue(PORT0, 11, 0);
    GPIOSetValue(PORT1, 2, 0);

    delay32Ms(0, 100);

    GPIOSetValue(PORT1, 0, 1);
    GPIOSetValue(PORT1, 1, 1);
    GPIOSetValue(PORT0, 11, 1);
    GPIOSetValue(PORT1, 2, 1);
   
delay32Ms(0, 100);

}

If there are someone who experienced that these 4 ports don't work write it.

Thanks,
0 件の賞賛
返信

1,654件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 23 02:41:21 MST 2012
It's confusing to read what you did and what you didn't without code :confused:

Perhaps you want to copy, reduce to the basic problem, export and post this project :)

I would risk 5 minutes and debug /scope it for you :rolleyes:
0 件の賞賛
返信

1,654件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Wed May 23 02:32:50 MST 2012
Danke fur Zero als immer,


Quote: Zero
Pins can be switched to different functions with IOCON registers
Some pin functions are not switched to GPIO at Reset (like pins you've mentioned) so you can't use them as GPIO before you switch them to GPIO via setting this IOCON function bits.
Did you try this already?
Note: Don't forget to set bit 16 (=IOCON) of SYSAHBCLKCTRL, otherwise IOCON registers can't be changed.



Sure I did.
And I wrote other lines that I've not written in the message.

LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16);
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<0);

And to prevent from switching to other function, I stopped to feed some clocks.

LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<12);
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<13);
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<14);

Now I'm thinking to alter strange Port to other ones.

Anyway thanks Zero,
0 件の賞賛
返信

1,654件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Wed May 23 02:22:07 MST 2012
Danke Zero als immer,


Quote: Zero
Pins can be switched to different functions with IOCON registers :eek:

I don't know to which function it turned but at least GPIO didn't work.

Some pin functions are not switched to GPIO at Reset (like pins you've  mentioned) so you can't use them as GPIO before you switch them to GPIO  via setting this IOCON function bits.
Did you try this already?

Sure, I did.
I wrote other lines into the source, like this.

LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16);
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<0);

And to prevent to switch other function, I stopped some clock feed as followings.

LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<12);
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<13);
LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<14);

Note: Don't forget to set bit 16 (=IOCON) of SYSAHBCLKCTRL, otherwise IOCON registers can't be changed.



Now I'm thinking I alter the Port that didn't work to other port.
I want know are there anyone who experienced like this.
Anyway thanks Zero
0 件の賞賛
返信

1,655件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 23 00:31:58 MST 2012
Pins can be switched to different functions with IOCON registers :eek:

Some pin functions are not switched to GPIO at Reset (like pins you've mentioned) so you can't use them as GPIO before you switch them to GPIO via setting this IOCON function bits.
Did you try this already?

Your debugger is showing you IOCON registers. To test this 'strange' pins you can just switch their pin functions to GPIO there, switch their direction to output and toggle them.
Debugger is your friend :)

Note: Don't forget to set bit 16 (=IOCON) of SYSAHBCLKCTRL, otherwise IOCON registers can't be changed.
0 件の賞賛
返信