Atmel AVR Microcontroller discussion group.
Can't get first C prgm working on Atmel AT90S2313. Help pls.... - John Preller - Aug 25 10:08:00 2005
All,
This is my first attempt at using C and using the AVR platform. I
used the Codevision AVR C compiler to automatically produce the code
below (as I have got a long road ahead of me before I can produce my
own code from scratch). The code is supposed to light an LED when the
corresponding push button in pushed. Problem is that the high order
LED (bit 7) is always on. All other LED's come on when you press the
corresponding push button, but LED 7 is always on. I can't see what
is causing it in the code. Can anyone shed some light on it for me
please?
Much appreciated.
Cheers
John
Code Below:
~~~~~~~~~~~~~~~~~~~~~
/*****************************************************
This program was produced by the
CodeWizardAVR V1.24.6 Evaluation
Automatic Program Generator
© Copyright 1998-2005 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
e-mail:office@offi...
Project :
Version :
Date : 25/08/2005
Author : Freeware, for evaluation and non-commercial use only
Company :
Comments:
Chip type : AT90S2313
Clock frequency : 3.680000 MHz
Memory model : Tiny
External SRAM size : 0
Data Stack size : 32
*****************************************************/
#include <90s2313.h>
// Declare your global variables here
void main(void)
{
// Declare your local variables here
int data;
// Input/Output Ports initialization
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out
Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0
State0=0
PORTB=0x00;
DDRB=0xFF;
// Port D initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1 output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1H=0x00;
OCR1L=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
GIMSK=0x00;
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
while (1)
{
data=PIND;
PORTB=data;
};
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Can't get first C prgm working on Atmel AT90S2313. Help pls.... - Zack Widup - Aug 25 10:28:00 2005
On Thu, 25 Aug 2005, John Preller wrote:
> All,
>
> This is my first attempt at using C and using the AVR platform. I
> used the Codevision AVR C compiler to automatically produce the code
> below (as I have got a long road ahead of me before I can produce my
> own code from scratch). The code is supposed to light an LED when the
> corresponding push button in pushed. Problem is that the high order
> LED (bit 7) is always on. All other LED's come on when you press the
> corresponding push button, but LED 7 is always on. I can't see what
> is causing it in the code. Can anyone shed some light on it for me
> please?
>
> Much appreciated.
>
> Cheers
> John
>
> Code Below:
>
> // Port D initialization
> // Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
> // State6=T State5=T State4=T State3=T State2=T State1=T State0=T
> PORTD=0x00;
> DDRD=0x00;
All I can see is maybe because you skipped "FUNC7" and "State7" in the
above code?
Zack

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
RE: [AVR club] Can't get first C prgm working on Atmel AT90S2313. Help pls.... - Juan Gabriel Aldana - Aug 25 11:16:00 2005
the code is ok, review your hardware.......
John Preller <john.preller@john...> escribió:All,
This is my first attempt at using C and using the AVR platform. I
used the Codevision AVR C compiler to automatically produce the code
below (as I have got a long road ahead of me before I can produce my
own code from scratch). The code is supposed to light an LED when the
corresponding push button in pushed. Problem is that the high order
LED (bit 7) is always on. All other LED's come on when you press the
corresponding push button, but LED 7 is always on. I can't see what
is causing it in the code. Can anyone shed some light on it for me
please?
Much appreciated.
Cheers
John
Code Below:
~~~~~~~~~~~~~~~~~~~~~
/*****************************************************
This program was produced by the
CodeWizardAVR V1.24.6 Evaluation
Automatic Program Generator
© Copyright 1998-2005 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
e-mail:office@offi...
Project :
Version :
Date : 25/08/2005
Author : Freeware, for evaluation and non-commercial use only
Company :
Comments:
Chip type : AT90S2313
Clock frequency : 3.680000 MHz
Memory model : Tiny
External SRAM size : 0
Data Stack size : 32
*****************************************************/
#include <90s2313.h>
// Declare your global variables here
void main(void)
{
// Declare your local variables here
int data;
// Input/Output Ports initialization
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out
Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0
State0=0
PORTB=0x00;
DDRB=0xFF;
// Port D initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1 output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1H=0x00;
OCR1L=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
GIMSK=0x00;
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
while (1)
{
data=PIND;
PORTB=data;
};
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Yahoo! Groups Links
---------------------------------
Correo Yahoo!
Comprueba qué es nuevo, aquí
http://correo.yahoo.es
[Non-text portions of this message have been removed]

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
RE: [AVR club] Can't get first C prgm working on Atmel AT90S2313. Help pls.... - Karsten Dudek - Aug 25 11:21:00 2005
Hi John,
change
int data;
to
unsigned char data;
because You have only 8 bit.
Regards Dudi
-----Original Message-----
From: avrclub@avrc... [mailto:avrclub@avrc...] On Behalf
Of John Preller
Sent: Thursday, August 25, 2005 4:08 PM
To: avrclub@avrc...
Subject: [AVR club] Can't get first C prgm working on Atmel AT90S2313.
Help pls....
All,
This is my first attempt at using C and using the AVR platform. I
used the Codevision AVR C compiler to automatically produce the code
below (as I have got a long road ahead of me before I can produce my
own code from scratch). The code is supposed to light an LED when the
corresponding push button in pushed. Problem is that the high order
LED (bit 7) is always on. All other LED's come on when you press the
corresponding push button, but LED 7 is always on. I can't see what
is causing it in the code. Can anyone shed some light on it for me
please?
Much appreciated.
Cheers
John
Code Below:
~~~~~~~~~~~~~~~~~~~~~
/*****************************************************
This program was produced by the
CodeWizardAVR V1.24.6 Evaluation
Automatic Program Generator
© Copyright 1998-2005 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
e-mail:office@offi...
Project :
Version :
Date : 25/08/2005
Author : Freeware, for evaluation and non-commercial use only
Company :
Comments:
Chip type : AT90S2313
Clock frequency : 3.680000 MHz
Memory model : Tiny
External SRAM size : 0
Data Stack size : 32
*****************************************************/
#include <90s2313.h>
// Declare your global variables here
void main(void)
{
// Declare your local variables here
int data;
// Input/Output Ports initialization
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out
Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0
State0=0
PORTB=0x00;
DDRB=0xFF;
// Port D initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1 output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1H=0x00;
OCR1L=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
GIMSK=0x00;
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
while (1)
{
data=PIND;
PORTB=data;
};
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Yahoo! Groups Links
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.15/80 - Release Date:
23.08.2005
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.15/80 - Release Date:
23.08.2005

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Can't get first C prgm working on Atmel AT90S2313. Help pls.... - Cláudio E. Elicker - Aug 25 18:15:00 2005
On Thursday 25 August 2005 11:08, John Preller wrote:
> All,
>
> This is my first attempt at using C and using the AVR platform. I
> used the Codevision AVR C compiler to automatically produce the code
> below (as I have got a long road ahead of me before I can produce my
> own code from scratch). The code is supposed to light an LED when the
> corresponding push button in pushed. Problem is that the high order
> LED (bit 7) is always on. All other LED's come on when you press the
> corresponding push button, but LED 7 is always on. I can't see what
> is causing it in the code. Can anyone shed some light on it for me
> please?
snip
> Chip type : AT90S2313
> Clock frequency : 3.680000 MHz
> Memory model : Tiny
> External SRAM size : 0
> Data Stack size : 32
> *****************************************************/
>
> #include <90s2313.h>
snip
> while (1)
> {
> data=PIND;
> PORTB=data;
>
> };
> }
There is no PD7 pin in the AT90S2313. Where did you connect the LED 7 push
button?
Cláudio

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )
Re: [AVR club] Can't get first C prgm working on Atmel AT90S2313. Help pls.... - John Preller - Aug 26 6:13:00 2005
Thanks All,
I got the answer and thought everyone may like to know as it may help
others starting out like me.
Someone else has correctly pointed out that the AT90S2313 has 1 x 8
bit port (Port B) and 1 x 7 bit port (Port D). My program (yeah the
whole two lines I wrote myself) continually scans Port D (only 7 bits)
and places the value out onto Port B (eight bits).
The highest order push button (SW7) is not connected to Port D.
Sounds simple when someone points it out - had me tearing my hair out
last night.
I suppose that's the real value of these groups. Thanks very much
everyone.
Regards
John
--- In avrclub@avrc..., "Cláudio E. Elicker" <elicker@g...> wrote:
> On Thursday 25 August 2005 11:08, John Preller wrote:
> > All,
> >
> > This is my first attempt at using C and using the AVR platform. I
> > used the Codevision AVR C compiler to automatically produce the code
> > below (as I have got a long road ahead of me before I can produce my
> > own code from scratch). The code is supposed to light an LED when the
> > corresponding push button in pushed. Problem is that the high order
> > LED (bit 7) is always on. All other LED's come on when you press the
> > corresponding push button, but LED 7 is always on. I can't see what
> > is causing it in the code. Can anyone shed some light on it for me
> > please?
> >
>
> snip
>
> >
> > Chip type : AT90S2313
> > Clock frequency : 3.680000 MHz
> > Memory model : Tiny
> > External SRAM size : 0
> > Data Stack size : 32
> > *****************************************************/
> >
> > #include <90s2313.h>
>
> snip
>
> >
> > while (1)
> > {
> > data=PIND;
> > PORTB=data;
> >
> > };
> > }
> There is no PD7 pin in the AT90S2313. Where did you connect the LED
7 push
> button?
>
> Cláudio
______________________________
controlSUITE software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com ) Re: [AVR club] Can't get first C prgm working on Atmel AT90S2313. Help pls.... - Zack Widup - Aug 26 9:36:00 2005
Duh - I should've spotted that. I haven't used the 2313 much, been mostly
using the mega8, mega16 and other mega's.
Zack
On Fri, 26 Aug 2005, John Preller wrote:
> Thanks All,
>
> I got the answer and thought everyone may like to know as it may help
> others starting out like me.
>
> Someone else has correctly pointed out that the AT90S2313 has 1 x 8
> bit port (Port B) and 1 x 7 bit port (Port D). My program (yeah the
> whole two lines I wrote myself) continually scans Port D (only 7 bits)
> and places the value out onto Port B (eight bits).
>
> The highest order push button (SW7) is not connected to Port D.
>
> Sounds simple when someone points it out - had me tearing my hair out
> last night.
>
> I suppose that's the real value of these groups. Thanks very much
> everyone.
>
> Regards
> John
______________________________
controlSUITE software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!

(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )