OV7670 with Propeller and C
d0nar
Posts: 3
in Propeller 1
Hey you all out there,
I am starting an Project with LoRa wireless and an OV7670 camera.
I have seen some projects out here, running the camera with spin, but i like C much more
At the moment, i think about feeding the camera's XCLK pin with an CLK generated from the Propeller.
My Problem is, how can i achieve an frequency of about at least 8MHz in C code at an pin?
I am using the Propeller ASC+.
Can somebody give me an hint?
Thanks in advice.
Greetings,
Daniel
I am starting an Project with LoRa wireless and an OV7670 camera.
I have seen some projects out here, running the camera with spin, but i like C much more
At the moment, i think about feeding the camera's XCLK pin with an CLK generated from the Propeller.
My Problem is, how can i achieve an frequency of about at least 8MHz in C code at an pin?
I am using the Propeller ASC+.
Can somebody give me an hint?
Thanks in advice.
Greetings,
Daniel
Comments
If you found a Spin object that satisfies your requirements, I would highly recommend throwing it through the Spin to C++ translator written by a fellow forum member called spin2cpp. There's pretty good instructions in the project's README which can be found on GitHub: https://github.com/totalspectrum/spin2cpp
I'm guessing you're using SimpleIDE, but if you're using PropWare by chance, then PropWare will automatically run spin2cpp over the Spin file for you. See the example here.
That might be a solution, but doing it my own, has a bigger learn effect
Maybe i will go this way to get some hints.
For now I am stuck with Omnia Creator and might give PropWare a chance, but only when i get it up and running with Clion, which is my preffered IDE.
Edit:
found that snippet for C
DIRA |= 1<<23;
FRQA = 12010943;
CTRA = (0x17<<23) + 23;
while(1) ;
but when i alter it like this
DIRA |= 1<<0; //Pin 0 as output
FRQA = 268435456; //get 8MHz
CTRA = (0x17<<0) + 0; //Pin 0 toggle at 8MHz
while(1);
it produces nothing on Pin 0
so could it be, that i have to look after the physical Pin number for using this?
Sorry for this question, never needed the low level stuff in propeller, low level was only on PIC16´s
The shift 23 on the CTRA assigment means to assign 0x17 to bits 31..23 of the CTRA register that controls the counter configuration (see the Propeller manual) and is not related to the pin number. The + 0 instead is ORin the pin number (bits 9..0) which is correct.
With the correction above it should work.
Makes sense
That's great! I didn't know anyone was using OmniaCreator - it's a fantastic IDE. Are you on Windows, Mac or Linux?
This comes out of PropWare and should work nicely for you. I tested it on my own machine and was able to hit a reliable 8 MHz with it. I imagine for other not-so-even numbers, you'd get a bit more jitter. But 8 MHz is a good choice .
Note that, in place of "convert(this->m_mask)" you'll just want to use "0" for your pin number. And, though PropWare's function doesn't include it, you are certainly correct to be setting the DIRA register as well.
oh okay
thank you for the explanation, sadly Pin 0 (i really hope Pin 0 in code is Pin 0 on the Board) seems just to give my Oscilloscope an ~1,8 V DC Signal (tested at several frequencies)
At the moment on Windows on my gaming rig, later i will use my laptop or workstation with arch, but for now i am too lazy to install my laptop and workstation all fresh with good old german telekom 660kB/s...
This will be done when the semester begins and then using the good w-lan ^^
A few things on Omnia annoy me, sometimes it crashes unexpectedly, sometimes it is not able to open the port, but i like the code completion freatures
I altered it now to this:
It seems to work, at least at a few khz, but with 8MHz it seems like a sinus wave, i think maybe my oscilloscope is there at his limit
but normaly the digital part should be able to record 20MHz without problems
at the analouge part it normaly should also work, 20MHz vertical and 2MHz horicontal
Have to say it is from 1986, got it just a year ago and for now i did only simple stuff with it^^