[SOLVED] Function delay_ms in CodeVision is doesnt work

Status
Not open for further replies.

tarose78

Junior Member level 2
Joined
Jul 22, 2012
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,441
Hi all,

I am building a very simple program using Atmega128 and CodeVision v2.05.3 with 11,059200Mhz crystal
I also configured at the project settings using the right CLOCK
Burned using USBASP with avrdude.
Below is the code...


I am expecting that the led1 is on at the first time followed by led2 is on then led3 is on at the next 100 ms.

But it doesnt work as I expected,
only led1 and led2 is on, but led3 is still off.
I am suggest that delay_ms() function is not working properly.

Am I missing something here ?
Please Help...
 

I search on every website about this and tried as they told to do.
- Using the latest version of Coldvision 3.05
- Pay attention to cpu clock, and in the Project Settings must be set exactly as the crystal attached to the board. ( for xtal, I use 11,0592 with 22pf capacitors)

Been there done that, but the problem still exists.

anybody will help?
 

just add a line after "led3_hi; " that "while(1);"

It'll work fine....
Post the response...

Thanks mathespbe for the response,

I tried that also, seems that the program stop or got returned when hit the function delay_ms(100);
so led3 is still off.
 

Thanks mathespbe for the response,

I tried that also, seems that the program stop or got returned when hit the function delay_ms(100);
so led3 is still off.

Instead of delay_ms(100), use a for loop delay...
Now check it whether the LED gets ON or not... If it does the problem exists because of this delay function...
just use a delay function as follows...

for(int i=0;i<100;i++)
for(int j=0;j<100;j++);
 

Now I modified as follow
The result is, led3 is ON. So, I guess it is something to do with delay_ms function.
So I try to create an empty function ( that will replace delay_ms ).
The entire code is as follow

From the above code, lay_ms() should be return nothing and the program should be continue to led3_hi;
But the fact is not, only led1 and led2 is ON but led3 still Off.

thats weird.
 

Use this code...
It must work fine....

Code:
#include <mega128.h>
#include <delay.h>
#define led1_hi PORTA.7=1
#define led2_hi PORTA.6=1
#define led3_hi PORTA.5=1

#define led1_lo PORTA.7=0
#define led2_lo PORTA.6=0
#define led3_lo PORTA.5=0
void lay_ms()
{
}

void main(void)
{
DDRA|=(1<<5);
DDRA|=(1<<6);
DDRA|=(1<<7);

led1_hi;
led2_hi;
lay_ms();
led3_hi;
while(1);
}
 

Tried that, but still same.
Perhaps there is something wrong with the board.

 

It is the schema, I use eagle but only for printing the board only.
It is working well with WinAVR + AvrDude.
_delay_ms() is working
void function is also working.

But not with Coldvision.
 

Got it.

My ATMega128 is brand new, m103 is should be deactivated.
So, I use Extreme AVR burner to set fusebit and set as follow
low 0xff
high 0xc9
extended 0xFF

That finally solved the problems.
Thanks for all the helps.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…