Hh Pallet Problem


Dex

Still Fresh
Joined
Feb 2, 2006
Messages
39
Hi all, i am working in a HH environment, as in no linux, the problem is setting pallet, i set all things for enabling LCD etc.
This all works fine, can fill screen with blocks of color or plot pixel, but the problem is if i set mode to RGB 8bit and set pallet its set the pallet (eg: color changes ) but not the right colors, eg set pallet first color (eg: 0) to 000000 give me white ?, which should be black, setting pallets second color to ffffff gives me blue, try as i may i can not seem to get black or red or green.

I have gone other my settings and have made sure things like cursor are disabled, i send the pallet as green +blue byte
Then 0 + red byte.

But this problem as been racking my brains, for a week now and i have run out of ideas.
 
I've noticed that as well, and all I can think of is that the LCD controller hasn't been set up correctly or something. How are you setting up the LCD controller?
 
Robster posted on Sep 28 2006 at 05:27 AM said:
I've noticed that as well, and all I can think of is that the LCD controller hasn't been set up correctly or something. How are you setting up the LCD controller?
MSP_DISPCSETREG = 0x5900
MSP_DPC_INTR = 0x0000
MSP_DPC_CLKCNTL= 0x0010
MSP_DPC_X_MAX = 319
MSP_DPC_Y_MAX = 239
MSP_DPC_HS_WIDTH = 0x041d
MSP_DPC_HS_END = 0x0009
MSP_DPC_HS_STR = 0x0009
MSP_DPC_DE = 0x0250
MSP_DPC_FPIPOL1 = 0x10
MSP_DPC_V_SYNC = 0x0f03
MSP_DPC_V_END = 0x0816
MSP_MLC_OVLAY_CNTR = 0x1004
MSP_MLC_STL_MIXMUX = 0
MSP_MLC_STL_ALPHAL = 0x0000
MSP_MLC_STL_ALPHAH = 0x0000
MSP_MLC_STL1_STX = 0
MSP_MLC_STL1_ENDX = 319
MSP_MLC_STL1_STY = 0
MSP_MLC_STL1_ENDY = 239
MSP_MLC_STL_CKEY_GB = 0xffff
MSP_MLC_STL_CKEY_R = 0x00ff
MSP_MLC_STL_HSC = 1024

;LcdDisable:
MSP_DPC_FPIATV1 = 0
MSP_DPC_FPIATV2 = 0
MSP_DPC_FPIATV3 = 0
MSP_DPC_CNTL = 4
MSP_DPC_FPICNTL = 1

;LcdEnable:
MSP_GPIOBOUT &= ~0x0c
MSP_GPIODOUT &= ~0x10
MSP_GPIOHOUT &= ~0x06
MSP_GPIOHOUT |= 0x08

MSP_DPC_FPIATV1 = 0xffff
MSP_DPC_FPIATV2 = 0xffff
MSP_DPC_FPIATV3 = 0xffff
MSP_DPC_FPICNTL = 0
MSP_DPC_CNTL |= 0x0001

sdk2x_USleep( 100 )

MSP_GPIOBOUT |= 0x0c
MSP_GPIODOUT |= 0x10
MSP_GPIOHOUT &= ~0x08
MSP_GPIOHOUT |= 0x06

;LcdInit:
call LcdDisable
call LcdRegisters
;for (16BPP)
MSP_MLC_STL_VSCL = 640
MSP_MLC_STL_VSCH = 640
MSP_MLC_STL_HW = 640
MSP_MLC_STL_CNTL = 0x4AB
;for (8BPP)
MSP_MLC_STL_VSCL = 320
MSP_MLC_STL_VSCH = 320
MSP_MLC_STL_HW = 320
MSP_MLC_STL_CNTL = 0x2AB
call LcdEnable

Note also have functions
LcdSetFrameBuffer
SetPalette etc.

Settings are from Rob Brown sdk2x, but i have rewritten them in full ARM ASM.
as i do not use C.
PS: Are you Rob Brown by any chance, if so your code has helped me loads thanks.
 
Last edited by a moderator:
Dex posted on Sep 27 2006 at 06:17 PM said:
Hi all, i am working in a HH environment, as in no linux, the problem is setting pallet, i set all things for enabling LCD etc.
This all works fine, can fill screen with blocks of color or plot pixel, but the problem is if i set mode to RGB 8bit and set pallet its set the pallet (eg: color changes ) but not the right colors, eg set pallet first color (eg: 0) to 000000 give me white ?, which should be black, setting pallets second color to ffffff gives me blue, try as i may i can not seem to get black or red or green.
Are you setting the palette index properly? You need to set 0x2958 to the index of the colour you're changing, this internal counter automatically increments by one every time two 16-bit read/writes are made to the data register (0x295A).
Can you give the snippit of code around where you're trying to set the colours?
I have gone other my settings and have made sure things like cursor are disabled, i send the pallet as green +blue byte
Then 0 + red byte.

But this problem as been racking my brains, for a week now and i have run out of ideas.
Are you really sending bytes? If so that may be the problem as the registers have to be read/written as shorts.
 
Last edited by a moderator:
First thanks for your inputs, here is the to write code, but i have also try may other ways of doing the same thing and get the same thing happens eg: wrong colors.
Note: this is assembled with fasm assembler, as it only converted to code ARM, thats why the code may look differant.
Code:
SetPallet:
		ldr   r1, [pc,MSP_MLC_STL_PALLT_A-$-8]; move 0xC0002958 into r1
		mov   r0, 0						   ; 0 for first color in pallet
		strh  r0, [r1]						; send it to address 0xC0002958

		mov   r0,  0						  ; 0 it just in case.
		add   r0,  pc,testPalette-$-8		 ; Points to pallet.
		ldr   r1, [pc,MSP_MLC_STL_PALLT_D-$-8]; points to 0xC000295A.
		mov   r3, 512						 ; 2 loops per color = 256 colors.
PalletLoop:
		ldrh  r5, [r0]
		strh  r5, [r1]
		add   r0, r0,2
		sub   r3,r3,1
		cmp   r3, 0
		bne   PalletLoop


MSP_MLC_STL_PALLT_A dw	 0xC0002958
MSP_MLC_STL_PALLT_D dw	 0xC000295A

testPalette:
dh 0xffff,0x00ff,0x0000,0x0000,0xff00,0x0000,0x00ff,0x0000
dh 0x0000,0x00ff,0x0000,0x0000,0xffff,0x0000,0x0000,0x0000
; more here

Also the pallet does change, but not to the colors it should eg: 0x00000000 comes out white, but it should be black, as rob pointed out, i think that in a full HH setting the set up of the LCD is wrong in someway as rob get the same problem.
Linux must set something differant, thats why it works normally in linux, most people will be working under linux so will not get this problem.

Thanks again Dex.
 
Ahh, after a quick check with register fiddling :)

1) My saying MSP_MLC_STL_PALLT_A incremented on every other read/write was wrong, it does infact increment every time, and only on setting the red component is the colour sent to the hardware palette.

2) You're setting MSP_MLC_STL_VSCH incorrectly. This is the HIGH part of _VSC and unless you're scaling then it should be set to 0 at all times (even with scaling you rarely need to use _VSCH.)
I think the reason people keep setting this register is because when you read from it, due to a hardware bug (I assume) it always returns the value of _VSCL. Together they make up the 25-bit VSC register so setting both to 320 results in a VSC of 20971840 - a scaling up of 65537 times! You'll end up with a screen where each pixel in the framebuffer is 240 pixels high on screen i.e. one row, and it may not even be the top row of the framebuffer.
 
Sure Robster, i will post it here as soon as i have the problem fixed.
And thanks again for your great work :) .
 
Does anyone know of a HH 8bit demo that gives correct pallet color, with code?.
As i have try everything, but still can not find it, open2x is too encrypt.
Thanks.
 
Back
Top