YesNoOk
avatar

Anyone knows programing firmware in C? (Read 6833 times)

Started by He-Man, September 06, 2007, 07:25:57 pm
Share this topic:
Anyone knows programing firmware in C?
#1  September 06, 2007, 07:25:57 pm
  • avatar
  • ***
Hey guys,

I was just wondering, does anyone of you know how to programe firmware in C?
Because I have a lab, and I get confused. :(

I need to lighten up a small LED (is it called right? A small lamp) - and write
a C program for it. While the programing itself shouldn't be too much of a trouble...
Knowing HOW to set values to correct ports? If anyone's willing to help, please tell me.
This is really hard. :(
The key to happiness is not to mourn on the past, or to worry about tomorrow - but to live here and now. In the present. Honestly and earnestly.
Re: Anyone knows programing firmware in C?
#2  September 06, 2007, 07:30:16 pm
  • ******
  • [E]
    • Mexico
what does it has to do with firmware ?

jsut look for tutorials on programming for hte paralell port in C.
Re: Anyone knows programing firmware in C?
#3  September 07, 2007, 02:37:48 am
  • ******
    • Germany
it depends on the type of processor you have... if it's for school or something it's probably an AtMega or something similar...
Re: Anyone knows programing firmware in C?
#4  September 07, 2007, 04:01:24 am
  • *****
    • Peru
Doing that shouldn't be harder than putting a 1 on a register :P
Re: Anyone knows programing firmware in C?
#5  September 07, 2007, 10:19:41 am
  • ******
  • Limited time to use Infinite power !
    • France
    • network.mugenguild.com/cybaster/
Re: Anyone knows programing firmware in C?
#6  September 07, 2007, 11:59:22 am
  • avatar
  • ***
Alright- Here's a bit info to clarify the problem.
I have the LPC2148 Education board. Now, I have to programe a LED in P0.14
to flash at a given delay time. This is my code:



#include <lpc2xxx.h>
#include <general.h>

int main()
{

PINSEL0 &= 0xBFFFFFFF; /*Pin choice*/

IODIR0 |= 0xDFFFFFFF; /*As output*/


IOSET0 = 0xDFFFFFFF;

/*Function Prototype*/
void delayNops(tU32 *nops);



while (1) {
/*On*/   
   IOCLR0 &= 0xDFFFFFFF;
/*Delay*/   
   delayNops((tU32)30000000);
/*Tända av*/   
   IOSET0 &= 0xBFFFFFFF;
/*Off*/
   delayNops((tU32)30000000);   
   
   }

}

delayNops(tU32 *nops)
{
   volatile tU32 i;
   
   for  (i = 0; i < *nops; i++)
      asm volatile ("nop");
}



Ok. Now it works for a moment, but goes crazy later.
It works normally and then flashes rapidly.
Until it stops working.

And then it says on the terminal:
" no answer on '?'"


I still can't figure out teh problem. :/
The key to happiness is not to mourn on the past, or to worry about tomorrow - but to live here and now. In the present. Honestly and earnestly.
Re: Anyone knows programing firmware in C?
#7  September 07, 2007, 01:22:42 pm
  • ******
    • Germany
I don't think that's the problem, but why do you use a volatile variable for the nop loop? you don't expect any outer influences, do you? :thinking:

Re: Anyone knows programing firmware in C?
#8  September 09, 2007, 12:52:06 pm
  • avatar
  • ***
I don't think that's the problem, but why do you use a volatile variable for the nop loop? you don't expect any outer influences, do you? :thinking:



Expect any other influences? I don't understand what you mean.  ???
We just started programing in C, and that piece of code "volatile", was just straight
copied from the LAB manual. It said we should use it.  :-\

I have tried for 3 days to make this thing to work - but I have nooo clue.
I've read to midnight, all the manuals we got - re-read the lab exercises... but no.
I really can't get what I am doing wrong.
The key to happiness is not to mourn on the past, or to worry about tomorrow - but to live here and now. In the present. Honestly and earnestly.
Re: Anyone knows programing firmware in C?
#9  September 09, 2007, 07:40:37 pm
  • ******
    • Germany
code looks ok to me... don't you have a teacher to ask, or something? or is there maybe some kind of support forum for that piece of hardware you got?
Re: Anyone knows programing firmware in C?
#10  September 12, 2007, 01:19:42 pm
  • avatar
  • ***
code looks ok to me... don't you have a teacher to ask, or something? or is there maybe some kind of support forum for that piece of hardware you got?

Yeah, I fixed it now. It was no error on the coding itself. The problem lied in what bits I wanted to have as output. Also, the problem lied mainly
in the board itself. Yes, teacher helped me a little and now I have found a Yahoo group for these kinds of things. Still - I need to get to know
C programing a little bit better, so I wanted to ask for a little more help. :)

Now that this one is done, we have got the problem that we have to make a separate file, called "delay.c". It will have a function as the delay.
BUT, the amount of delay will have to be set as the input parameters. So, if I type 500 ms, then the delay will be 500 ms. And this part is what
I have a little hard with. How do I program in C that it reads from the keyboard, and inputs it in the functions parameter? I only recognize it from
JAVA programing, but in C... I'm not sure how. :/ Any assistance would be very appriciated. :)
The key to happiness is not to mourn on the past, or to worry about tomorrow - but to live here and now. In the present. Honestly and earnestly.
Re: Anyone knows programing firmware in C?
#11  September 12, 2007, 04:35:26 pm
  • ******
  • [E]
    • Mexico
for reading from the keyboard use scanf , though getc can also help, scanf is more noob friendly.