Atmega32 with codivisionavr + proteus

Go To Last Post
42 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone.

Please, I need of the help with code generated with codevision to atmega32 + lcd, it's working in proteus simulator, but not in physical circuit, was made to simple lcd of 4 bits, any can tell me why this happens, thanks...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

THINK: What things could possibly be different between the Simulation, and your physical circuit?

 

The most obvious is to check that your physical circuit actually matches what you simulated - isn't it?

 

  • Wiring correct?
  • Correct components?
  • Correct component values?
  • Power supply correct - and turned on!
  • Have you actually programmed the correct code into the chip?
  • etc
  • etc ...

 

Image result for ibm think

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks awneil, the circuit and the schematic in the proteus are the same...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Take a picture of your hardware and post it, do you have bypass caps on all vcc/gnd pin pairs? 

Do you have power on all VCC and AVCC pins?

What is your clock source, internal R/C or external Xtal? 

What are your fuse settings? 

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Often Proteus allows implementations that will not work in the "real" world:

  • Does the uC have proper bypass caps?
  • Are the fuses in the uC properly set?
  • Is the circuit properly grounded?

 

Showing a schematic of your physical system would help us help you.

 

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The board

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The code..

 


Chip type               : ATmega8535
Program type            : Application
AVR Core Clock frequency: 8,000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 128
*****************************************************/

#include <mega8535.h>

// Alphanumeric LCD Module functions
#include <alcd.h>
#include <delay.h>
// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A 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
PORTA=0x00;
DDRA=0xFF;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T 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
// Mode: Normal top=0xFF
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer1 Stopped
// Mode: Normal top=0xFFFF
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer2 Stopped
// Mode: Normal top=0xFF
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// USART disabled
UCSRB=0x00;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC disabled
ADCSRA=0x00;

// SPI initialization
// SPI disabled
SPCR=0x00;

// TWI initialization
// TWI disabled
TWCR=0x00;

// Alphanumeric LCD initialization
// Connections specified in the
// Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
// RS - PORTA Bit 0
// RD - PORTA Bit 1
// EN - PORTA Bit 2
// D4 - PORTA Bit 4
// D5 - PORTA Bit 5
// D6 - PORTA Bit 6
// D7 - PORTA Bit 7
// Characters/line: 8
lcd_init(8);

while (1)
      {
      lcd_puts("Carlos");

      }
}

 

Last Edited: Thu. May 25, 2017 - 01:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In proteus working with 8mhz clock frequêncy.

 

Adding that with both the atmega32 and the atmega8535 this occurs, I'm finding this to be due to lcd, but it's new and I've already switched to another one the same ..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Check your pin numbering - eg,  look where pin 40 is:

http://www.atmel.com/images/doc2... - page 2

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. May 25, 2017 - 12:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There seems to be a regulator wired up at the bottom R?/H side of the bread board but I can't see any MANDATORY bypass caps on that just as I can't see any on the chip itself.

 

But then I see that the pot's V+ is coming directly from VA.

 

Please do you drawing EXACTLY as wired up. ALL GND and VCC pins must be wired up and decoupled with bypass caps including AGND and AVCC, this is not optional.

 

EDIT I fixed yous code format, please use the code button when posing code <>, also as it has been pointed out the chip wiring is nothing like the schematic.

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Thu. May 25, 2017 - 01:41 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

CarlosConde wrote:
the circuit and the schematic in the proteus are the same...

No - it is now quite clear that they are not!!

 

js wrote:
Please do you drawing EXACTLY as wired up.

It would help if you also posted a photo in which we can see the connections to the LCD - in #6, they are hidden in shadow.

 

Also, if you could get a clear close-up of the connections at the microcontroller

 

please use the code button when posing code <>

Detailed instructions here: https://www.avrfreaks.net/comment...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. May 25, 2017 - 07:39 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

CarlosConde wrote:
the circuit and the schematic in the proteus are the same...

No - it is now quite clear that they are not!!

 

That^^^^^

 

 

@OP...to start with, and it's not the only error, your schematic shows the LCD connected to Port A but on the breadboard it's on Port C.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So many things wrong seen in that picture.

 

1) micro has two pairs of power / ground pins, they must all be connected to the power source and must have bypass caps (100nf) placed near the micro.

2) The xtal is placed too far from the micro, move it so it is in the same row(s) and remove the blue wires.

3) I would suggest you get a hold of one of the breadboard power supply boards instead of using individual parts/pieces.

Like one of these.