VB.NET Sample - LED Control

nicolas
Posts: 162
Joined: Sun Jun 07, 2009 4:32 pm

VB.NET Sample - LED Control

Post by nicolas » Thu Oct 08, 2009 6:51 pm

Here is a sample I made for controlling the LED's.
Its quite simple; mind you it took me some 3 days to figure it all out.

Ive since added more features to my s3c2440 and mini2440 vb classes.
Ill release those updates with the other samples.
Whats to come...
- ADC Reading
- Control of Backlight


And here is the little readme I made for it...
Mini2440_Sample_Led
--------------------

This app demonstrates control of the LED's on the Mini2440 board.


This sample program was written in VB.Net CF2.0 with Visual Basic 2005
It requires the Compact Framework 2.0 be installed on the destination target.

Included are two VB classes that help in accessing the Mini2440 and the S3C2440 cpu written by me.
Im constantly revising them and will update accordingly.

As for the CFIO.dll, it is a container for the modified C# class PhysicalAddressPointer from OpenNETCF.
Please see other zip for source.



Enjoy.


Nicolas (Nicolas AT Gomez DOT cc)
Edit: Maybe the admin will make this sticky.
Attachments
Mini2440_Sample_LED.zip
(35.09 KiB) Downloaded 2366 times

esky-sh
Posts: 1664
Joined: Sat Dec 20, 2008 4:21 am

Re: VB.NET Sample - LED Control

Post by esky-sh » Thu Oct 08, 2009 7:34 pm

Thanks a lot for sharing your codes with us!

xgrunt24
Posts: 3
Joined: Tue Sep 08, 2009 9:08 pm

Re: VB.NET Sample - LED Control

Post by xgrunt24 » Wed Dec 02, 2009 11:30 pm

Will your modifed PhysicalAddressPointer point to any NAND address location? Does it require that you address at the 32bit word start or can you for example do an 8bit read/write? What is the integer &H1 that is being passed to it?
Thanks

nicolas
Posts: 162
Joined: Sun Jun 07, 2009 4:32 pm

Re: VB.NET Sample - LED Control

Post by nicolas » Thu Dec 03, 2009 8:52 am

The PhysicalAddressPointer class is made to read/write to the memory, specifically memory mapped registers.
I have not tried to use it to read/write from the nand, it should be possible.

I have only tried accessing the s3c2440 registers, and therefore only tried 32 bit read/write.
The full documentation on the class can be found at OpenNetCF. Its part of theyr work.

Ill post the class source up today - hopefully.

ergunkk
Posts: 4
Joined: Wed Jan 20, 2010 10:58 pm

Re: VB.NET Sample - LED Control

Post by ergunkk » Sat Feb 06, 2010 2:30 am

Thanks for code

i tried code in embedded ce 6. after buildind it gives some warnings like;

Warning 1 Return type of function 'ADCDAT0' is not CLS-compliant.
Warning 2 Return type of function 'ADCDAT1' is not CLS-compliant.
Warning 3 Return type of function 'ADCCON' is not CLS-compliant.
Warning 4 Return type of function 'GPGDAT' is not CLS-compliant.
Warning 5 Return type of function 'GPBDAT' is not CLS-compliant.
Warning 6 Return type of function 'GPBCON' is not CLS-compliant.
Warning 7 Return type of function 'GPBUP' is not CLS-compliant.
Warning 8 Return type of function 'GPGCON' is not CLS-compliant.
Warning 9 Return type of function 'GPGUP' is not CLS-compliant.
Warning 10 Return type of function 'TCFG0' is not CLS-compliant.
Warning 11 Return type of function 'TCFG1' is not CLS-compliant.
Warning 12 Return type of function 'TCNTB0' is not CLS-compliant.
Warning 13 Return type of function 'TCMPB0' is not CLS-compliant.
Warning 14 Return type of function 'TCNTB1' is not CLS-compliant.
Warning 15 Return type of function 'TCMPB1' is not CLS-compliant.
Warning 16 Return type of function 'TCON' is not CLS-compliant.
Warning 17 Return type of function 'LCDCON1' is not CLS-compliant.
Warning 18 Return type of function 'LCDCON5' is not CLS-compliant.


when i pressed a button on screen, program stops, and it gives "ArgumentNullException" error.

how can i solve the problem?

nicolas
Posts: 162
Joined: Sun Jun 07, 2009 4:32 pm

Re: VB.NET Sample - LED Control

Post by nicolas » Sat Feb 06, 2010 1:10 pm

I beleive that the sample will NOT work on CE 6 due to changes to the architecture and memory access.
For CE6 you should use the kernel drivers included, the same way the samples in CE6 image work.

nawaphun
Posts: 2
Joined: Thu Feb 11, 2010 8:19 pm

Re: VB.NET Sample - LED Control

Post by nawaphun » Fri Feb 12, 2010 6:31 am

nicolas, thank you for your post i have use your example but i can't use function "ADCCON()" i think that because of "Shared iADCCON As New PhysicalAddressPointer(&H58000000, &H1)". pls tell me how to use this function for chanel adc(0) to adc(4) in mini2440 thank you very much.
Last edited by nawaphun on Sat Feb 13, 2010 9:21 am, edited 1 time in total.

nicolas
Posts: 162
Joined: Sun Jun 07, 2009 4:32 pm

Re: VB.NET Sample - LED Control

Post by nicolas » Fri Feb 12, 2010 8:49 am

Thats because the LED sample code does NOT include the code to use the ADC.
It has the structure so that you can make said functionality yourself.
Just read the datasheet and figure outwhat registers you need to set/read and that should be it.

nawaphun
Posts: 2
Joined: Thu Feb 11, 2010 8:19 pm

Re: VB.NET Sample - LED Control

Post by nawaphun » Sat Feb 13, 2010 9:19 am

nicolas, Today i have many tried to read manual but i have only seen "0x58000000" for adccon.
before this i download example in c++ from friendlyarm.net i think this code is a address of adc
int CALLBACK ReadAdc(int ch)
{
m_p2440ADC->rADCCON = (1<<14)|(20<<6)|(ch<<3); //setup channel
m_p2440ADC->rADCCON|=0x1; //start ADC
while(m_p2440ADC->rADCCON&0x1); //check if Enable_start is low
while(!(m_p2440ADC->rADCCON&0x8000)); //check if EC(End of Conversion)flag is high
return ((int)m_p2440ADC->rADCDAT0 & 0x3ff);
}
but I have no knowledge in embledded hardware and c++
please give me an example in VB2005 code
Many thanks.

nicolas
Posts: 162
Joined: Sun Jun 07, 2009 4:32 pm

Re: VB.NET Sample - LED Control

Post by nicolas » Sat Feb 13, 2010 6:26 pm

Im sorry but I dont have the time right now to provide a full sample.
The code you have is a great starter, simply need to translate it to the vb.net and using the sample i provided.

Code: Select all

int CALLBACK ReadAdc(int ch) 
{ 
m_p2440ADC->rADCCON = (1<<14)|(20<<6)|(ch<<3); //setup channel 
m_p2440ADC->rADCCON|=0x1; //start ADC 
while(m_p2440ADC->rADCCON&0x1); //check if Enable_start is low 
while(!(m_p2440ADC->rADCCON&0x8000)); //check if EC(End of Conversion)flag is high 
return ((int)m_p2440ADC->rADCDAT0 & 0x3ff); 
}

Code: Select all

m_p2440ADC->rADCCON
That is the register for ADCCON, goto the datasheet and find the address for this (if i havent already defined it) and copy one of the register define lines inm y code.

Code: Select all

(1<<14)|(20<<6)|(ch<<3); 
That is binary operations on CH. Look up some C/C++ reference/tutorials on what those mean. << is a left shift of bits, and | is an bitwise or.

The rest of the code should be self eplanatory. You loop thru reading the reigster until its ready. Then you actually ready the register and AND it with 3ff.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest