Clocking an mbed

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

Clocking an mbed

2,381件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Sun Mar 21 11:34:58 MST 2010
I am using an mbed in the LPCExpresso IDE and am trying to set the clock to 100Mhz. I am not using CMSIS.

In the file system_LPC17xx.c I have modifed the following values

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PLL0CFG_Val 0x00020031 [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//0x00050063[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]#define[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] CCLKCFG_Val 0x00000003 [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//0x00000003[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]which should give me an M=50, N=2 and Div = 4 to give 100Mhz.[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f]In main.c I have the following simple code to turn on/off an LED[/COLOR][/SIZE]
[SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE] [/LEFT]
[SIZE=2][LEFT][/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]while[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](1) {
LPC_GPIO2->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]FIOSET[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = TEST_1;
LPC_GPIO2->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]FIOCLR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = TEST_1;[/LEFT]
}

The time to execute the two FIOSET/FIOCLR lines is ~40ns and the time for the complete while loop is 110 nsecs. 

This is about 4 times slower than the same loop run in code from the mbed compiler (10 and 40 nsec respectively). The mbed figures were what I expected and I don't understand what is happening using the LPCExpresso compiler.

In a related problem, if CCLKCFG_Val is set to 2, an error message is emitted during compiling system_LPC17xx.c,

"[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#error[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] "CCLKCFG: CCLKSEL field does not contain only odd values or 0!".[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2] I don't see why this should be an error, there is no mention of this in user.manual.lpc17xx.pdf, nor does it give an error message with the mbed compiler.[/SIZE]

Any help would be most appreciated,

John Robbins.
[SIZE=2][/SIZE]
[SIZE=2]
[/SIZE][/SIZE][LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f] [/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE]
0 件の賞賛
返信
10 返答(返信)

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Thu Mar 25 09:47:00 MST 2010
Hi,

Thanks for the code samples. I tried using both the EINT1 and EINT2 variants without any more success than previously. Actually, I think my earlier code was pretty well identical to yours. No response in the interrupt handlers in edge mode.

I wanted to use the external interrupts in preference to setting a pair of ports as interrupts as I found earlier that their response was not fast enough for my application.

I am thinking of getting one of the Hitex 1768 sticks but I am not sure that I can use your compiler with it?

I am now totally out of ideas and am ready to abandon this approach.

As usual any ideas are welcome.

John.
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Wed Mar 24 11:18:29 MST 2010
Attached is some example code that uses EINT0-2 on the LPC1768 and has been tested on the Keil MCB1700 board. Hopefully this will help you resolve the issue you are seeing.
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Wed Mar 24 05:56:23 MST 2010
Thanks for the reference. I looked at it and I seem to be doing exactly the same as in the reference, except that I am trying to use EINT1 and EINT2. I need two interrupt inputs and on the MBED EINT0 is already tied into the 'mystery' interface chip.

I would get one of the other LPC1768 boards, eg the Hitex stick, which does have external connections for the EINT lines but I would like to be sure that all the interrupt lines in the LPC1768 do work in edge triggered mode. Is it possible that there are some errata on the subject?

Once again, thanks for your continuing help.

John.
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Tue Mar 23 16:44:53 MST 2010
Take a look at the following application note:

http://ics.nxp.com/support/documents/microcontrollers/zip/an10915.zip

It contains code to set EINT0 into edge triggered mode which should give you a good starting point.
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Tue Mar 23 06:05:31 MST 2010

Quote: NXP_USA
The macro that checks the value of CCLKSEL is a hang over from a previous series of devices where it was not possible to set an even value for this field. However this restriction is not present in the LPC17xx series. The user manual correctly defines the allowed values for the CCLKSEL field on the LPC17xx: 2-255 only (0 and 1 are not allowed).

If you wish to use an even value then I suggest commenting out this macro.

Hope this is of help



Yes, this is what I had done but I was not sure that it was legal!

I am still having problems using EINT1 and EINT2 in edge triggered mode. Are there any code examples that work in this mode?

Thanks again for your help

John.
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Mon Mar 22 16:52:06 MST 2010
The macro that checks the value of CCLKSEL is a hang over from a previous series of devices where it was not possible to set an even value for this field. However this restriction is not present in the LPC17xx series. The user manual correctly defines the allowed values for the CCLKSEL field on the LPC17xx: 2-255 only (0 and 1 are not allowed).

If you wish to use an even value then I suggest commenting out this macro.

Hope this is of help
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Mon Mar 22 14:15:47 MST 2010
With regards to the error...

"#error "CCLKCFG: CCLKSEL field does not contain only odd values or 0!"

This restriction on CCLKCFG appears to have come from the initial draft versions of the LPC17xx user manual - upon which the CMSIS code and headers for LPC17xx were originally written. But the restriction does not appear to exist in the current release version of the user manual.

I assume that the CCLKCFG restriction has been lifted on production silicon - hopefully someone from NXP will be able to confirm.

[As an aside the CCLKCFG restriction also appears to be documented for the LPC23xx, which has many similarities with the LPC17xx.]

Regards,

CodeRedSupport
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Mon Mar 22 11:34:34 MST 2010
I have recompiled and indeed the speed is now approximately the same as from the mbed compiler - so thank you very much - now I don't know why I did not think of the answer for myself.

Another question - the reason for switching from the mbed environment was to try and get some code working using EINT1 and EINT2 (with fine wires connected to the pins which are not brought out on the mbed).

I could not get the interrupt handlers working in edge mode triggering. The trigger sources are square waves so if I use level mode, multiple triggers were generated. Do you have any code example of EINT1 and EINT2 being used in edge mode?

Thanks again,

John.
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JohnR on Mon Mar 22 11:09:37 MST 2010
Thanks for the answer - I will try again shortly.

Do you have any answer for my second question re the
"
[SIZE=2]an error message is emitted during compiling system_LPC17xx.c,

"[COLOR=#0000ff][COLOR=#0000ff]#error[/COLOR][/COLOR] "CCLKCFG: CCLKSEL field does not contain only odd values or 0!".[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]"[/SIZE]
[SIZE=2]as this does not seem to be mentioned in the data sheet.[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]John.[/SIZE]




[SIZE=2][/SIZE]
0 件の賞賛
返信

2,296件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Mon Mar 22 08:33:39 MST 2010
Hi,

Are you building the code for Debug or Release?

I think the mbed compiler is only building for Release (i.e. with a high level of optimizations, as they don't support debug).

The default settings for the LPCXpresso compiler is for Debug (i.e. NO optimizations, so that the code is easily debugged). If you build for Release, you should see very similar performance.
0 件の賞賛
返信