9 years, 8 months ago.

Portin data for OV7670

Hi fellow mbed community, after reading through the code used to initialise the pins for D7-D0 at main.h (http://developer.mbed.org/users/edodm85/code/OV7670_Test_Code_with_ethernet/file/df8de18d7fa9/main.h),

would like to know how do you know the the pin numbers to be Port0,0x07878000, to be the p18(P0.26),p17(P0.25),p16(P0.24),p15(P0.23),p11(P0.18),p12(P0.17),p14(P0.16),p13(P0.15, I'm trying to do the same for Kl25Z, would like to know if there's a way to find out what hex code for pins that I wish to declare?

from PortName port, 8bit bus port int mask, 0b0000_0M65_4000_0321_L000_0000_0000_0000 = 0x07878000

http://developer.mbed.org/users/edodm85/code/ov7670/file/119b4c04a4ed/ov7670.h

Question relating to:

Test Code for OV7670 Camera module with FIFO AL422 OV7670

Now that I know that it is using "PortIn" function which reads all the bits from a particular port, and masking off the unused pins.

To determine the hex numbers would first require to know which pins on a port needs to be used and which isn't. Constraint comes in as the pins placement would be restricted to a single port, and will need to mask off unused pins.

The question now is.. how to know if the ports I'm using is Port0 or Port1... etc.

posted by Tzer Maan Choo 25 Feb 2015

Did you find the correct way of constructing the byte from the PortIn output? I' m having a hard time with it, it' s so obscure!

posted by angelo mottolese 16 Nov 2016

Hi, It's been years since, and I have not found the correct way of doing it as there isn't much guide on how to deal with it.

If you have found the solution, do let me know as well.

Cheers

posted by Tzer Maan Choo 19 Nov 2016

Solution found! After digging Edoardo' s code, I found this function: int result = (((data&0x07800000)>>19)|((data&0x078000)>>15)); data is the pointer to PortIn. It works for me! PS your pin order is correct

posted by angelo mottolese 21 Nov 2016

1 Answer

5 years, 2 months ago.

It seems like the Mask is written in Hexadecimal: 0x07878000

However the Mask is actually working in binary, which is below, counting the binary from right to left:

  • 00000111 10000111 10000000 00000000

which are 26, 25, 24, 23, 18, 17, 16, 15

PortIn p(Port0, 0x07878000) >>>>> P0_26, P0_25, P0_24, P0_23, P0_18, P0_17, P0_16, P0_15

And another example is from the awful MBED _APIS: https://os.mbed.com/docs/mbed-os/v5.13/apis/portin.html

PortIn p(Port2, 0x0000003F)

0x0000003F to Binary >>>> 00111111

therefore

PortIn p(Port2, 0x0000003F) >>>> P2_5, P2_4, P2_3, P2_2, P2_1, P2_0