Atmega 644P fuse settings

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

Hello everyone, 

I am trying to set fuse of at mega 644P to use external crystal oscillator 16MHz for serial communication using RS232. I am quite confused about the settings. I tried calculating the values from online but that confused me even more. So did not want to risk with FUSE. Hence the post. 

Thanks in advance.

 

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

For 16 MHz I would use one of the full swing modes like:

 

 

I guess that you are using 5V so the BOD should be set at 4.3V also

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Fri. Apr 14, 2017 - 03:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for your response. Will try it out and get back.

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

Thank you so much. I followed this set up and was able to serially communicate through USB. But the same is not working when i switch to MAX3232 . Is there anything that i have to keep in mind when i am switching. I am trying to collect data from a sensor through MAX3232. Thank you :)

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

shamili1992 wrote:

Thank you so much. I followed this set up and was able to serially communicate through USB. But the same is not working when i switch to MAX3232 . Is there anything that i have to keep in mind when i am switching. I am trying to collect data from a sensor through MAX3232. Thank you :)

 

Its hard to know what you mean by "is not working"?  Please be more specific and if possible show a schematic or picture of your setup. 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

ki0bk wrote:

 

 

Its hard to know what you mean by "is not working"?  Please be more specific and if possible show a schematic or picture of your setup. 

Sorry about that. What i meant to say is that i am not able to communicate serially through MAX3232. I do not see any values being returned from the sensor to MCU when connected to MAX3232 through DB9.

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

Can you do a loopback test......  i.e. connect TXD to RXD on the db9 and see what your sending?

How is your db9 wired, DTE or DCE? 

Are you using a normal (modem) or crossed(null-modem) serial cable?

Like I said, a schematic and or picture is worth a k of words.

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

please find attached schematic of the design. I have been using cable for communication and not modem

Attachment(s): 

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

The capacitors used for the MAX3232 are not the recommended values, look at the application note for the chip.

 

Don't know what kind of regulator you are using (no part number) but they usually require 100nF caps close to the chip, the same applies for the micro (usually one per VCC/GND pair).

 

Disconnect AREF from VCC you may end up damaging the chip.

 

You seem to have the OUT pin of the MAX3232 going to the TX pin of the chip, causing conflict.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:

The capacitors used for the MAX3232 are not the recommended values, look at the application note for the chip.

 

Don't know what kind of regulator you are using (no part number) but they usually require 100nF caps close to the chip, the same applies for the micro (usually one per VCC/GND pair).

 

Disconnect AREF from VCC you may end up damaging the chip.

 

You seem to have the OUT pin of the MAX3232 going to the TX pin of the chip, causing conflict.

You are right. Thank you for your response. It really helped me a lot. 

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

For others who may happen on this, MAX232 and their cousins have pins labeled IN and OUT on the logic side. These names refer to the signal directions REFERENCED TO THE INTERFACE. That is, OUT is the  OUT to the U(S)ART which connects to RXD on the AVR. Likewise, the IN connects to the TXD of the AVR because a signal is coming IN to the interface from the AVR U(S)ART.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

Continuing to work on this, I am trying to obtain a value out of sensor  to my MCU which i can use for calculations. Please find attached the log from sensor. Here, i want to extract the value from 4th column. I have written the program below. I don't understand two things: 

1. what is the end of the line?? (IS it /n or carriage return etc.,). 

2. I tried to test for all the terminator operators but still was not able to get any values. Any input is welcome. 

 

Thank you!

 

#ifndef F_CPU
#define F_CPU 16000000UL // 1 MHz clock speed
#endif

#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include <stdio.h>
#include <avr/interrupt.h>
#include "lcd.h"


#define BAUD 38400                    // define baud
#define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)    // set baudrate value for UBRR


#define D0 eS_PORTB0
#define D1 eS_PORTB1
#define D2 eS_PORTB2
#define D3 eS_PORTB3
#define D4 eS_PORTB4
#define D5 eS_PORTB5
#define D6 eS_PORTB6
#define D7 eS_PORTB7
#define RS eS_PORTD5
#define RW eS_PORTD6
#define EN eS_PORTD7


void uart_init (void);
void uart_transmit (unsigned char data);
unsigned char uart_recieve (void);


void uart_init (void)
{
	UBRR0H=(BAUDRATE>>8);
	UBRR0L=BAUDRATE;                         //set baud rate
	UCSR0B|=(1<<TXEN0)|(1<<RXEN0);             //enable receiver and transmitter
	UCSR0C|=(0<<USBS0)|(3<<UCSZ00);// 8bit data format
	
}

// function to send data - NOT REQUIRED FOR THIS PROGRAM IMPLEMENTATION
void uart_transmit (unsigned char data)
{
	while (!( UCSR0A & (1<<UDRE0)));            // wait while register is free
	UDR0 = data;                             // load data in the register
}

// function to receive data
unsigned char uart_recieve (void)
{
	while(!(UCSR0A & (1<<RXC0)));           // wait while data is being received
	return UDR0;                             // return 8-bit data
}

int main (void)
{
	DDRB = 0xFF;
	DDRD = 0xFF;
	Lcd8_Init();
	Lcd8_Clear();
	Lcd8_Cmd(0x80);
	Lcd8_Write_String(" values:");
	
	uart_init();							 // initialize UART
	char x ,count=0 ,buffer[50],a=0, j=0,i=0,c[6] ;
	
	do
	{
		x= uart_recieve();
		buffer[i] = x;
		i++;
	} while (x != 0x0D);
	for(a=0;a<i;a++)
	{
		while(buffer[a] == 0x44)
		{
			count = count +1;
			if(count == 3)
			{
				
				for(j=0;j<5;j++)
				{
					c[j] = buffer[a++];
					a++;
				}
			}
		}
	}
	
	c[j++] = '\0';
	Lcd8_Set_Cursor(2,1);
	Lcd8_Write_String(c);
}


 

Attachment(s): 

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

EOL can be anything, though it is usually a <CR> character but could be a <LF>, you will need to confirm what is being sent.

A logic analyzer is a good tool to verify your serial data, or a terminal program that will display control characters is handy too.

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

In general, if you are trying to decipher output from a device, it is a good idea to receive a group of characters from the device and (since you apparently have an operational lcd) then display the hex values of the data to analyze just what is being sent. As ki0bk said the EOL could be anything (including multiple characters).

David (aka frog_jr)

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

Thank you for your response. It really helped. I tried to receive a group of characters from the device and display on LCD. But, on the two  lines of LCD, each line from the sensor is separately displayed(the lines are not displayed continuously one after the other instead they break and display the first entry from sensor on first line of LCD and display next entry on second line ) .  Basically, i am not getting the entire line. Is there any way i can fix this? 

 

Thank you. 

Sorry if what i said isn't clear enough.

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

I tried to receive a group of characters from the device and display on LCD

But that may not work for characters below 0x20 like CR/LF unless you test for that and then display something in place of the actual character.

 

It is best to dump all characters into a buffer and then look at the buffer with a debugger.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:

I tried to receive a group of characters from the device and display on LCD

But that may not work for characters below 0x20 like CR/LF unless you test for that and then display something in place of the actual character.

 

It is best to dump all characters into a buffer and then look at the buffer with a debugger.

Thank you. Could you give me an idea like how can i look in through debugger? like any steps? and what debugger to use . I have never used one so just  want to go in the right way.

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

The Atmel ICE is the current all round debugger both for Atmel AVR and ARM chips, not necessarily a cheap option but not too expensive either. It will be a good investment for the future.

 

For the Mega644P you will need to use the JTAG header provided you have one on your board, otherwise things get messy.

 

Once your code compiles correctly you use the "Start Debugging and Break" options from Debug, this will program the code into your chip and you can run your code, once you think you have enough character into you buffer you can look at the buffer using the Watch windows and you can see what has been received.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:

The Atmel ICE is the current all round debugger both for Atmel AVR and ARM chips, not necessarily a cheap option but not too expensive either. It will be a good investment for the future.

 

For the Mega644P you will need to use the JTAG header provided you have one on your board, otherwise things get messy.

 

Once your code compiles correctly you use the "Start Debugging and Break" options from Debug, this will program the code into your chip and you can run your code, once you think you have enough character into you buffer you can look at the buffer using the Watch windows and you can see what has been received.

Thank you for your suggestion but i do not have a JTAG header on my board but i am using ATMEL-ICE . Is there any other alternative to obtain the end of the line?? 

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

i am using ATMEL-ICE

Are you using it for ISP only then? What does you board look like? You may be able to add a JTAG connector.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:

i am using ATMEL-ICE

Are you using it for ISP only then? What does you board look like? You may be able to add a JTAG connector.


Yes i am using it only for ISP now.