Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Help with C program on ATmel AT90S2313 (beginner)

Help with C program on ATmel AT90S2313 (beginner)

2005-08-25 by John Preller

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@hpinfotech.com

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;
      
            };
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RE: [AVR-Chat] Help with C program on ATmel AT90S2313 (beginner)

2005-08-25 by Brian Fairchild

Have you checked your hardware?
 
Brian
Show quoted textHide quoted text
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
Behalf Of John Preller
Sent: 25 August 2005 15:06
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] Help with C program on ATmel AT90S2313 (beginner)


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
C Copyright 1998-2005 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
e-mail:office@hpinfotech.com

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 


	
*	 Visit your group "AVR-Chat
<http://groups.yahoo.com/group/AVR-Chat> " on the web.
  

*	 To unsubscribe from this group, send an email to:
 AVR-Chat-unsubscribe@yahoogroups.com
<mailto:AVR-Chat-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
  

*	 Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 


  _____

Re: Help with C program on ATmel AT90S2313 (beginner)

2005-08-26 by John Preller

Thanks Brian, yes h/w is all O.K.

I got the answer from the 'AVR-Club' and thought everyone may like to
know as it may help others starting out like me.

Someone else has 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

p.s. Probably back with more dumb questions as my learning journey
goes.  Thanks all for your feedback.


--- In AVR-Chat@yahoogroups.com, "Brian Fairchild" <b.fairchild@d...>
wrote:
Show quoted textHide quoted text
> Have you checked your hardware?
>  
> Brian
> 
> -----Original Message-----
> From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
> Behalf Of John Preller
> Sent: 25 August 2005 15:06
> To: AVR-Chat@yahoogroups.com
> Subject: [AVR-Chat] Help with C program on ATmel AT90S2313 (beginner)
> 
> 
> 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
> C Copyright 1998-2005 Pavel Haiduc, HP InfoTech s.r.l.
> http://www.hpinfotech.com
> e-mail:office@h...
> 
> 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 
> 
> 
> 	
> *	 Visit your group "AVR-Chat
> <http://groups.yahoo.com/group/AVR-Chat> " on the web.
>   
> 
> *	 To unsubscribe from this group, send an email to:
>  AVR-Chat-unsubscribe@yahoogroups.com
> <mailto:AVR-Chat-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
>   
> 
> *	 Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> . 
> 
> 
>   _____

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.