Getting LPC1114 up running, controlling backlight (asm)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting LPC1114 up running, controlling backlight (asm)

850 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by EI24 on Wed Jun 17 11:38:33 MST 2015
Hi, i recently bought a LPC1114 based board( /https://www.olimex.com/Products/ARM/NXP/LPC-H1114/ ). I have a TFT screen backlight wire connected to PIO0_3 pin(14 on the board). The screen lights up, because of the pull-up. Im trying to shut the backlight off, by simply changing the pin to pull-down. However the backlight is still on. The code assembles fine without errors, and i can successfully download it to the MCU. I'm using the fasmarm assembler. Any idea what could be wrong?

Here is my code:


LDRr0 , [PIO0_3_adr]        ;load IOCONFIG_PIO0_3 reg adress
MOVr1 , 0x8        ;select pulldown(0b1000)
STRr1 , [r0 , 0]        ;store in IOCONFIG_PIO0_3 reg


PIO0_3_adr:
dw0x4004402C



Thanks for responses!
Labels (1)
0 Kudos
11 Replies

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by EI24 on Fri Jun 26 09:24:40 MST 2015
Ok, i suspected that. when i step through the code with the JLink programmer, the STR instructions seem to work as the should. Also now i see that i was setting GIO0DIR  to 0... Now when i changed my code everything works, the screen turns black!

Thanks for helping me! :)
On the MCU i programmed on before this one i had some problem getting code on the chip and set everything up. Which can be tedious and drain your motivation. Also can take alot of time, as in my case..
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Fri Jun 26 07:20:24 MST 2015
You need to write a 1 to the relevant bit of DIR to set it as an output.

Once it's an output, whether it is pull-up or pull-down is irrelevant as that only applies to inputs.

0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by EI24 on Fri Jun 26 06:39:44 MST 2015
Hi, thanks for the response. I have not consciously set the IOCON clock. Though in trying to set up the arm-none-eabi, i messed up many times and downloaded 40kB of junk code and executed that code. So it may be that i have changed some things in the MCU. 
Is not the pin set to output? 0(default) is input and 1 out i read in the datasheet.
No i have not learned gnu gdb yet, which is what i will have to use. I just got everthing to work yesterday. Though i get step through the program mem with the program software, i will try that!
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Fri Jun 26 06:18:35 MST 2015
Did you set IOCON clock in SYSAHBCLKCTRL before?

Why is this pin an input?

Did you debug your code?
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by EI24 on Fri Jun 26 06:06:42 MST 2015
Hi again! I have got the programmer software right. I switched to arm-none-eabi toolchain which made things easier after i set it up. Now when i execute a simple program like MOVS r0, #0x5. The results are as intended. I changed the code so that the pin is pull-down, data direction to output and and then output zero to the pin. Though i get the same result(the backlight is still on). I think i may be using STR wrong.
Here is the new code:

.globalmain
.org 0x1000

main:
MOVSr1 , #0x0//used for clearing the regs
LDRr0 , =0x50008000//load GPIO0DIR address
STRr1 , [r0]//clear GPIO0DIR reg

LDRr0 , =0x50000000//set GPIODATA register to 0
STRr1 , [r0]//clear GPIO0DATA reg

MOVSr1 , #0x8//used to set pull-down
LDRr0, =0x4004402C//load IOCON_PIO0_3  address

STRr1 , [r0]//set reg
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by EI24 on Mon Jun 22 04:45:02 MST 2015
Didn't know of Stonehenge, seems like a cool place to visit!

Ok, that may be part of the problem. I tried to download, MOVS r0, #0x5  instead. But got the same result. The fasmarm assembler has some strange ways to specify your architecture. You don't simply specify your core, MCU or architecture(arm_architecture_v6m). For thumb16  i have to specify(which i think stands for architecture) CPU_CAPABILITY_V4T, *V5T, *V6T, *6M, *7M and *ALLIGN. So i think this and/or the J-Link downloader is the problem.
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Mon Jun 22 02:15:06 MST 2015
Happy solstice - I see from the BBC that for once it wasn't cloudy at Stonehenge!

Check your syntax. . .

There is no such instruction
MOV r0,0x5
, on a Cortex M0 and so your assembler will have to guess whether you mean
MOV R0,R5
MOVS R0,R5
or
MOVS R0,#0x05
.

My guess is that it will go for
MOVS R0,R5
, so you won't end up with 5 in R0, you will get whatever you had in R5.
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by EI24 on Sun Jun 21 01:02:12 MST 2015
Hi again, sorry for being slow(big celebration day in my country came up(midsommar)). I think maybe im assembling for the wrong architecture, or something is wrong with my download program. When i download a simply program like, MOV r0, 0x5. When i check the regs, r0 has not changed its value. I have posted my problem to the J-Link forum, im still waiting for a response. 
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Thu Jun 18 13:38:49 MST 2015
I've not used the fasmarm assembler - I use the one that comes with LPCXpresso. However, the instructions should be compatible.

The instructions should read:

LDR R0,=PIO0_3adr
MOVS R1,#0x08
STR R1,[R0]

PIO0_3adr: dw 0x40044023


because the ones you have are not in the correct format for the version of Thumb instruction set in the LPC1114.
I'm surprised the assembler doesn't flag up errors.

If you are driving the backlight from PIO0_3 then you have it configured it as an output. Pull-ups and Pull-downs won't source or sink anywhere near enough current to light a backlight.
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by EI24 on Thu Jun 18 01:12:41 MST 2015
In the LPC111X datasheet(UM10398). It notes in section 12.3.2,  that the reset value is input for all PIOx IO ports, im fairly certain i haven't changed them. I will try to change the GPIO0DATA reg as you said. When i analyse at the registers through the programmer software(JLinkExe), all the regs are filled with junk data. When i download the code with a simple, MOV r0, #0x8 , r0 does not change. So im suspecting there is something  wrong either with my assembler(maybe im assembling for the wrong architecture). Or something to do with the programmer software.

Best regards
0 Kudos

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by IanB on Wed Jun 17 23:27:22 MST 2015
It's unlikely that the screen will light up due to the pull-up resistor as the pull-up current is <85µA, so I suspect that the pin is configured as an output in the GPIO0DIR register.
If so, you need to change bit 3 of the GPIO0DATA register to a zero.
0 Kudos