Hi! I have some troubles with SiLabs c8051f041. I try to start very simple program - flashing one led on gpio. I use Keil CA51 Compiler Kit. Program succesfully compilates without errors. Then I program my chip c8051f041 with BeeProg+ programmer. When programming is succesfully finished, I try to power ON my chip. And nothing happened... I don't understand what I am doing wrong?
I don't think anyone else knows either - you haven't given much details.
But how do you know nothing happens? How is the LED connected? Have you looked at the processor pin with an oscilloscope or multimeter? Does the oscillator spin up? What does your code look like.
Thanks for quik answer. I configure the XBR0=0 - port1 pins is digital out puts and P0MDOUT=0b10000000 - P0.7 is push-pull output. Anod of LED is connected to P0.7 through resistor 1k to GND I connect the oscilloscope to LED pin and see the half of Vdd on this pin. Then I connect the oscilloscope to P1.7 (I write XBR1=0b10000000 SYSCLK routed to Port pin.) and I see the half of Vdd on this pin. I must see SYSCLK, but I see nothing.
It's my main.c:
//----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include <c8051f040.h> // SFR declarations //----------------------------------------------------------------------------- // Function PROTOTYPES //----------------------------------------------------------------------------- void SYSCLK_IntOsc_Init (void); //----------------------------------------------------------------------------- // MAIN Routine //----------------------------------------------------------------------------- void main (void) { WDTCN = 0xde; // disable watchdog timer WDTCN = 0xad; // select Internal Oscillator how the system clock SYSCLK_IntOsc_Init (); XBR0=0; //P0 pins is digital out puts P0MDOUT=0b10000000; // P0.7 is push-pull output XBR1=0b10000000; //SYSCLK routed to Port pin while (1) { P0 |=(1<<7); //LED ON P0 &= ~(1<<7); //LED OFF } }
This is a very, very, very fast blink:
while (1) { P0 |=(1<<7); //LED ON P0 &= ~(1<<7); //LED OFF }
How do you expect to see the LED blink when it is blinking many, many, many times faster than the human eye can see?
You either need to use an oscilloscope to look at that processor pin, or you need to introduce a delay between on->off and between off->on.
A pin that quickly toggles between GND and VCC will look like VCC/2 when you measure with a slow multimeter.
Another thing to remember is that your processor is rather unique and supports single-bit writes to the processor port pins - you can create a one-bit variable mapped to the LED pin and then just assign the value 0 or 1 instead of doing the |= and &= assigns.
I use an oscilloscope to see the meandr vaiwform on pin, but see the half of Vdd. I was try single bit operation:
sbit LED=P0^7;
. and then in main:
LED=1; for(i=0;i!=0xff;++i); LED=0; Result - NOTHING.
. I worry about no SISCLK on pin, were it must to be. Why it happing?
Another common reason for seeing an I/O pin having a voltage somewhere in the middle is when it's an input, or tristated output, without any pull-up/pull-down to hold it properly to VCC or GND.
That would happen if your initialization fails to set it as an output, or if the processor fails to run any program at all.
Why " the processor fails to run any program at all"? What's reason of it? My initialisation is wrong or chip is damange? I was try it on three chips, not only one. I want to see at least out of SYSCLK on pin where is he must to be. Becous it confirm the SYSCLK running.
I do not see you enabling the crossbar, any bit in the xbr registers is irrelevant till you enable the crossbar (xbr2.6 / BBARE)
Erik
I forgot write it. On this notebook I have not Keil IDE fnd I wrote what I remember. Of course, I enable the crossbar at the end of initialisation of ports.
XBR2 = 0x40;
.
I wrote what I remember. numerous hhreads have gone waaay astray because someone "wrote something" instead of copying actual code. Please refrain from doing so
I'm sorry. I tried to test the controllers in the workplace and after the failure at the weekend decided to ask for help. This does not excuse my confusion, but I would like to solve this problem by Monday, but the code remains at the working computer.