Problem with programmers

Go To Last Post
53 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys..

 

I'm writing GCC with AtmelStudio and I have two programmers. Atmel Ice, and TNM Programmer.

TNM Programmer link:

http://www.tnmelectronics.com/en/product/universal-programmer-5000/

 

in my previous project I worked with TNM and have no problem, every thing was ok as I expected, but in new one I'm programming with Atmel Ice, no problem with it and device working correctly, but with TNM, they're some problems!! my MCU resets in the end of code and does wrong things!! what is the problem??

This topic has a solution.

...

Last Edited: Wed. Oct 25, 2017 - 07:14 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the second Thread on TNM programmers not working within the last couple of days.

 

If the micro works properly when programmed with the Atmel ICE, then clearly the hardware and the software are fine, and the new variable to the equation is the TNM programmer.

 

I suggest you eMail them and tell them there appears to be a bug in their programming software.

 

JC

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

Watchdog fuse bit?

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

DocJC wrote:
This is the second Thread on TNM programmers not working within the last couple of days.

http://www.avrfreaks.net/forum/problem-after-fuse-bit-programming-xmega64a3u-tnm-2000

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

Brian Fairchild wrote:

Watchdog fuse bit?

It's enabled

...

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

DocJC wrote:

This is the second Thread on TNM programmers not working within the last couple of days.

 

If the micro works properly when programmed with the Atmel ICE, then clearly the hardware and the software are fine, and the new variable to the equation is the TNM programmer.

 

I suggest you eMail them and tell them there appears to be a bug in their programming software.

 

JC

 

It might be a hardware problem in my circuit!! when the AtmelIce programmer connector is connected to my circuit, it's ok but when connector is disconnected or TNM connector is connected the problem apears..

should I do any hardware job for protecting or something like that with any programmers??

...

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

Are you sure your uc is powered on the 5v and ground sides when Atmel ICE is disconnected?

Perhaps Atmel ICE gives power from PC to your uC; once removed, other power circuit is not enough... not wired.

Edited : can you post the schematics of your new circuit?

Last Edited: Mon. Oct 23, 2017 - 11:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dbrion0606 wrote:
Are you sure your uc is powered on the 5v and ground sides when Atmel ICE is disconnected?

yes I'm pretty sure, I have a fine power supply... 

 

dbrion0606 wrote:
can you post the schematics of your new circuit?

It's very very simple circuit which uc is connected to a GSM module and sends AT commands and I watch this commands with a USB TTL to serial convertor, and also a programmer 

...

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

So.. Not possible to post schematics then?

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:

So.. Not possible to post schematics then?

 

In fact I have no schematics!! I just work with this circuit on breadboard.. and I'm so lazy to make schematic file frownindecision

...

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

Perhaps, you should take a picture -"smart" "phones" can do it-

Broad beards have shaky wires, unsoldered connections: do you really believe enough current can power you MCU? Perhaps shaking it / hitting it will fix things.... for a while..

 

Sometimes, peole manage to have cards which keep the layout of a broad beard, are cheaper  and can be soldered (if the unsoldered version works, by a miracle, they can reproduce it without drawing schematics)  https://hackspark.fr/fr/solderable-mini-breadboard-pcb.html

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

sasan.riahi wrote:
nd I'm so lazy to make schematic file

Then that lowers your chances to get an answer to

should I do any hardware job for protecting or something like that with any programmers??

drastically.

 

1) Why should anyone bother to put in time to help you when you yourself is too lazy to give reasonable facts? If you're lazy so will the people you ask for help be.

 

2) Without a proper formal description of the circuit, detailing all connections and including all components, you can only get general advice like these:

- Don't create any short circuits

- Don't break any connections that actually should be made

- Don't enable any "phantom" power feeds

- Avoid ground loops

etc

 

Your call..

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:
Why should anyone bother to put in time to help you when you yourself is too lazy to give reasonable facts? If you're lazy so will the people you ask for help be.
 

dbrion0606 wrote:
Perhaps, you should take a picture -"smart" "phones" can do it-

 

I will send schematic files and photo tomorrow.. Now I'm not at work and have no access to boards.. 

 

thank for your responses

...

Last Edited: Mon. Oct 23, 2017 - 01:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sasan.riahi wrote:
I will send schematic files and photo tomorrow.. 

Instructions on how to properly post them: http://www.avrfreaks.net/comment...

 

and please take some effort to make good, clear, in-focus, well-lit photographs!

 

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

dbrion0606 wrote:
Broad beards

laugh

 

Another example of a solderable breadboard here: 

SparkFun Solder-able Breadboard

 

And, of course, there are the "traditional" prototyping boards:

 

Image result for veroboard Image result for veroboard Image result for veroboard  Image result for veroboard

 

EDIT

 

I thought I had included the Sparkfun link: https://www.sparkfun.com/products/12070

 

Last Edited: Mon. Oct 23, 2017 - 01:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@awneil : this is the very solderable,  read minibreadboards. Advantages w/r tradicional prototyping beards:

holes are metallic; even if one makes vey lousy solderings, it may work ... for a while (and one can find a magnifier to resolder completely).

color is more beautiful

row and column numbers are identified

Last Edited: Mon. Oct 23, 2017 - 02:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dbrion0606 wrote:
Sometimes, peole manage to have cards which keep the layout of a broad beard, are cheaper  and can be soldered ...
Another source that's in Calgary (Alberta, Canada) with more than several distributors :

http://www.busboard.com/pcbbreadboards

variants of that for hand-held plastic and aluminum (cast or extruded) enclosures.

 

"Dare to be naïve." - Buckminster Fuller

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

keep the layout of a broad beard

apparently ....a winner  :)

 

 

When in the dark remember-the future looks brighter than ever.

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

This is my complete board schematic:

 

 

I should add that I have two 7805, one for SIM800 and another for other components.

I message a number to GSM Module and it will be shown in 7Segments.

As I have told before, problem shows up in initialing SIM800 module. When I program ATMEGA8 with ATMEL ICE, thers no problem and when I program with TNM, code operates well until last AT Command, and then there are corrupted datas sent...

In other projects I had no problem with TNM!

 

This is my complete code:

 

#define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <avr/pgmspace.h>

#include "Define.h"
#include "MSG.h"
#include "Func.h"

// Definitions

#define TEST_LED_ON		PORTC&=~(1<<PORTC3);
#define TEST_LED_OFF	PORTC|=(1<<PORTC3);

// Define Functions

	// UART Functions
		void UART_TX (unsigned char);	// Send Character

	// GSM Functions
		void Proess_Data (void);
		void Init_MCU (void);
		void Init_GSM (void);
		void Process_SMS (void);
		void Send_SMS (unsigned char);

// Define Variables

	// UART Variables
		unsigned char R_Data=0;
		volatile unsigned char R_Data_Buffer[255];

	// GSM Variables
		unsigned char Msg_Num=0;		// Number of ME in GSM Module
		unsigned char Phone_Number [13];

	// Counters
		unsigned char Buffer_Counter=0;
		unsigned char MSG_Buff_C=0;

	// Flags
		char Buffer_Received_f=0,OK_f=0,Antenna_OK_f=0,Reg_OK_f=0;
		char Msg_Received_f=0,Msg_Sent_f=0;
		volatile char Msg_Read_f=0,P_MSG_f=0;

int main(void)
{
	MSG_Buff_C=0;
	Init_MCU();

	Init_GSM();

	while (1)
	{

		wdt_reset();
		_delay_ms(1000);
		if (Msg_Received_f)
		{
			Msg_Received_f=0;
			Phone_Num_Detect();
		}
		if (P_MSG_f)
		{
			P_MSG_f=0;
			Process_SMS();
		}

	}

	// Functions

// UART Functions
//////////////////////////////////////////////////////////////////////////
//					UART TRANSMIT
//////////////////////////////////////////////////////////////////////////
void UART_TX (unsigned char data)
{
	while (!( UCSRA & (1<<UDRE)));                // wait while register is free
	UDR = data;                                   // load data in the register
}
//////////////////////////////////////////////////////////////////////////
//					UART RECEIVE INTERRUPT
//////////////////////////////////////////////////////////////////////////
ISR (USART_RXC_vect)
{
	cli();

	while(!(UCSRA) && (1<<RXC));                   // wait while data is being received

	R_Data=UDR;
	R_Data_Buffer[Buffer_Counter]=R_Data;
	if (Buffer_Counter<100) Buffer_Counter++;

	 //If Data is Completed
	if (R_Data==0x0a)
	{
		//Buffer_Received_f=1;
		// OK Answer
		if (R_Data_Buffer[0]=='O' && R_Data_Buffer[1]=='K')
		{
			OK_f=1;
		}
		if (R_Data_Buffer[0]=='E' && R_Data_Buffer[1]=='R' && R_Data_Buffer[2]=='R' && R_Data_Buffer[3]=='O' && R_Data_Buffer[4]=='R')
		{
			OK_f=0;
		}
		// Registry OK
		if (R_Data_Buffer[0]=='+' && R_Data_Buffer[1]=='C' && R_Data_Buffer[2]=='R' && R_Data_Buffer[3]=='E' && R_Data_Buffer[4]=='G' && R_Data_Buffer[5]==':' && R_Data_Buffer[6]==' ' && R_Data_Buffer[7]=='0' && R_Data_Buffer[9]=='1')
		{
			 Reg_OK_f=1;
		}
		// CSQ Answer
		if (R_Data_Buffer[0]=='+' && R_Data_Buffer[1]=='C' && R_Data_Buffer[2]=='S' && R_Data_Buffer[3]=='Q' && R_Data_Buffer[4]==':' && R_Data_Buffer[5]==' ')
		{
			if (R_Data_Buffer[6]>'0')	Antenna_OK_f=1;
		}
		// MSG Received
		if (R_Data_Buffer[0]=='+' && R_Data_Buffer[1]=='C' && R_Data_Buffer[2]=='M' && R_Data_Buffer[3]=='T' && R_Data_Buffer[4]=='I' && R_Data_Buffer[5]==':' && R_Data_Buffer[6]==' ')
		{
			Msg_Received_f=1;
			Msg_Num = R_Data_Buffer[12];
		}
		// MSG Read
		if (R_Data_Buffer[0]=='+' && R_Data_Buffer[1]=='C' && R_Data_Buffer[2]=='M' && R_Data_Buffer[3]=='G' && R_Data_Buffer[4]=='R' && R_Data_Buffer[5]==':' && R_Data_Buffer[6]==' ')
		{
			 Msg_Read_f=1;
		}
		// Process Message
		if (R_Data_Buffer[0]=='N' && R_Data_Buffer[1]=='m' && R_Data_Buffer[2]=='s' && R_Data_Buffer[3]=='g' && R_Data_Buffer[4]==':')
		{
			P_MSG_f=1;
		}
		// MSG Sent
		if (R_Data_Buffer[0]=='+' && R_Data_Buffer[1]=='C' && R_Data_Buffer[2]=='M' && R_Data_Buffer[3]=='G' && R_Data_Buffer[4]=='S' && R_Data_Buffer[5]==':' && R_Data_Buffer[6]==' ')
		{
			Msg_Sent_f=1;
		}

		Buffer_Counter=0;
	}
	sei();
}

// Initial Functions
//////////////////////////////////////////////////////////////////////////
//					MCU Initial
//////////////////////////////////////////////////////////////////////////
void Init_MCU ()
{
	// IO Configuration
	DDRC=0b00001000;						// C3 Test LED
	PORTC=0b00101000;						// C5 pull up

	// B0 => A
	// B1 => B
	// B2 => C
	// B3 => D
	// B4 => S1
	// B5 => S2
	// B6 => S3
	DDRB=(0<<DDRB7)|(1<<DDRB6)|(1<<DDRB5)|(1<<DDRB4)|(1<<DDRB3)|(1<<DDRB2)|(1<<DDRB1)|(1<<DDRB0);
	PORTB=0;

	sei();
	// USART initialization
	// Communication Parameters: 8 Data, 1 Stop, No Parity
	// USART Receiver: On
	// USART Transmitter: On
	// USART Mode: Asynchronous
	// USART Baud Rate: 9600
	UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM);
	UCSRB=(1<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
	UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
	UBRRH=0x00;
	UBRRL=0x33;

	// Watchdog Timer initialization
	// Watchdog Timer Prescaler: OSC/2048k
	WDTCR=(1<<WDCE) | (1<<WDE) | (1<<WDP2) | (1<<WDP1) | (1<<WDP0);
	WDTCR=(0<<WDCE) | (1<<WDE) | (1<<WDP2) | (1<<WDP1) | (1<<WDP0);

}
//////////////////////////////////////////////////////////////////////////
//					GSM Initial
//////////////////////////////////////////////////////////////////////////
void Init_GSM ()
{
	// Check Connection
	while (!OK_f)
	{
		wdt_reset();
		UART_TX('A');
		UART_TX('T');
		UART_TX(13);
		_delay_ms(500);
	}
	OK_f=0;

	while (!Reg_OK_f)
	{
		wdt_reset();
		UART_TX('A');
		UART_TX('T');
		UART_TX('+');
		UART_TX('C');
		UART_TX('R');
		UART_TX('E');
		UART_TX('G');
		UART_TX('?');
		UART_TX(13);
		_delay_ms(1000);
	}
	Reg_OK_f=0;

	// Echo on
	wdt_reset();
	UART_TX('A');
	UART_TX('T');
	UART_TX('E');
	UART_TX('1');
	UART_TX(13);
	_delay_ms(500);

	// Delete Messages
	wdt_reset();
	UART_TX('A');
	UART_TX('T');
	UART_TX('+');
	UART_TX('C');
	UART_TX('M');
	UART_TX('G');
	UART_TX('D');
	UART_TX('=');
	UART_TX('1');
	UART_TX(',');
	UART_TX('4');
	UART_TX(13);
	_delay_ms(1000);

	// Message Format to text mode
	wdt_reset();
	UART_TX('A');
	UART_TX('T');
	UART_TX('+');
	UART_TX('C');
	UART_TX('M');
	UART_TX('G');
	UART_TX('F');
	UART_TX('=');
	UART_TX('1');
	UART_TX(13);
	_delay_ms(500);

	// URC Presentation
	wdt_reset();
	UART_TX('A');
	UART_TX('T');
	UART_TX('+');
	UART_TX('C');
	UART_TX('I');
	UART_TX('U');
	UART_TX('R');
	UART_TX('C');
	UART_TX('=');
	UART_TX('1');
	UART_TX(13);
	_delay_ms(500);

	// USSD Code Enable
	wdt_reset();
	UART_TX('A');
	UART_TX('T');
	UART_TX('+');
	UART_TX('C');
	UART_TX('U');
	UART_TX('S');
	UART_TX('D');
	UART_TX('=');
	UART_TX('1');
	UART_TX(13);
	_delay_ms(500);

	wdt_reset();
	UART_TX('A');
	UART_TX('T');
	UART_TX('D');
	UART_TX('*');
	UART_TX('1');
	UART_TX('4');
	UART_TX('1');
	UART_TX('*');
	UART_TX('1');
	UART_TX('#');
	UART_TX(';');
	UART_TX(13);
	_delay_ms(500);

}

// GSM Functions

//////////////////////////////////////////////////////////////////////////
//					Detect Phone Number of SMS Sender
//////////////////////////////////////////////////////////////////////////
void Phone_Num_Detect ()
{
	unsigned char _c=0;
	wdt_reset();
	UART_TX('A');
	UART_TX('T');
	UART_TX('+');
	UART_TX('C');
	UART_TX('M');
	UART_TX('G');
	UART_TX('R');
	UART_TX('=');
	UART_TX(Msg_Num);
	UART_TX(13);

	while (!Msg_Read_f)  wdt_reset();
	Msg_Read_f=0;
	for (_c=0;_c<13;_c++)
	{
		Phone_Number[_c]=R_Data_Buffer[_c+21];
	}

}
//////////////////////////////////////////////////////////////////////////
//					Process Received SMS
//////////////////////////////////////////////////////////////////////////
void Process_SMS ()
{
	if (R_Data_Buffer[5]=='A')
	{
		Send_SMS(0);
	}
	else if (R_Data_Buffer[5]=='O')
	{
		Send_SMS(1);
	}
}
//////////////////////////////////////////////////////////////////////////
//					Send Back SMS
//////////////////////////////////////////////////////////////////////////
void Send_SMS(unsigned char n)
{
	unsigned char _c=0,i=0;
	unsigned char Txt=0;

	// AT+CMGS...

	while (!OK_f)
	{
		wdt_reset();
		UART_TX('A');
		UART_TX('T');
		UART_TX(13);
		_delay_ms(500);
	}
	OK_f=0;

	UART_TX('A');
	UART_TX('T');
	UART_TX('+');
	UART_TX('C');
	UART_TX('M');
	UART_TX('G');
	UART_TX('S');
	UART_TX('=');
	UART_TX('"');
	for (i=0;i<13;i++)
	{
		UART_TX(Phone_Number[i]);
	}
	UART_TX('"');
	UART_TX(13);
	_delay_ms(50);
	Txt=pgm_read_byte(&(SMS_Msg[0][0]));
	while (Txt)
	{
		wdt_reset();
		Txt=pgm_read_byte(&(SMS_Msg[n][_c++]));
		UART_TX(Txt);
	}
	UART_TX(26);
	while (!Msg_Sent_f)
	{
		wdt_reset();
		_delay_ms(10);

	}
	Msg_Sent_f=0;
}

 

...

Last Edited: Tue. Oct 24, 2017 - 06:28 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, if it is a school project, your teacher will be happy... and if it is a hobby project, you should think of soldering it,  to keep it without lose wires (a lot of them)

 

You should add decoupling capacitors

(a) to MCU (2)

(b) to 4511

(c) to 7805-s (one at  input, the other at each  output, very near the regulator's pins)

 

Edited : looked at the code, too... and did not see where you manage7 segment display... (perhaps, to make things simpler, you might disconnect it?)

Last Edited: Tue. Oct 24, 2017 - 07:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dbrion0606 wrote:
Well, if it is a school project, your teacher will be happy...

 

This is small part of a bigger industrial project.

 

I found out something that it could cause the problem..

when programming is done, RESET pin in programmer is about 2.5v, since while programming it's between 0 and 5v. I tried to pull it up with 1k and 10k resistor, but it doesn't change, even a little!!

...

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

sasan.riahi wrote:

When I program ATMEGA8 with ATMEL ICE, thers no problem and when I program with TNM, code operates well until last AT Command, and then there are corrupted datas sent...

 

Please try this...

 

1) Zip up your .hex file and post it here

2) Program your mega8 with the TNM using the same .hex file

3) Read the flash of your mega8 with the ICE, save the .hex file, zip it up and post it here

 

So you will post two .zip files. One is the original file from the compiler, the other is the contents of your mega8's flash after being programmed by the TNM.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1
	UART_TX('A');
	UART_TX('T');
	UART_TX('+');
	UART_TX('C');
	UART_TX('M');
	UART_TX('G');
	UART_TX('F');
	UART_TX('=');
	UART_TX('1');
        UART_TX(13);

Just a passing remark but don't you see a bit of inefficiency here? (if nothing else it's TONS of typing to achieve something that should be simple). Consider doing this:

void Uart_Tx (unsigned char data)
{
	while (!( UCSRA & (1<<UDRE)));                // wait while register is free
	UDR = data;                                   // load data in the register
}

Uart_Tx_Str(char * str) {
    while (*str) {
        Uart_Tx(*str++);
    }
}

Now you can use:

        Uart_Tx_str("AT+CMGF=1\r");

and the same for all your other multiple bursts of UART_TX(c).

 

BTW I renamed the function to mixed case. Don't use function names like UART_TX in all upper case as most programmers will expect that to be a macro not a function.

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

Brian Fairchild wrote:

sasan.riahi wrote:

When I program ATMEGA8 with ATMEL ICE, thers no problem and when I program with TNM, code operates well until last AT Command, and then there are corrupted datas sent...

 

Please try this...

 

1) Zip up your .hex file and post it here

2) Program your mega8 with the TNM using the same .hex file

3) Read the flash of your mega8 with the ICE, save the .hex file, zip it up and post it here

 

So you will post two .zip files. One is the original file from the compiler, the other is the contents of your mega8's flash after being programmed by the TNM.

 

Ok, I attached two files

Attachment(s): 

...

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

clawson wrote:

	UART_TX('A');
	UART_TX('T');
	UART_TX('+');
	UART_TX('C');
	UART_TX('M');
	UART_TX('G');
	UART_TX('F');
	UART_TX('=');
	UART_TX('1');
        UART_TX(13);

Just a passing remark but don't you see a bit of inefficiency here? (if nothing else it's TONS of typing to achieve something that should be simple). Consider doing this:

void Uart_Tx (unsigned char data)
{
	while (!( UCSRA & (1<<UDRE)));                // wait while register is free
	UDR = data;                                   // load data in the register
}

Uart_Tx_Str(char * str) {
    while (*str) {
        Uart_Tx(*str++);
    }
}

Now you can use:

        Uart_Tx_str("AT+CMGF=1\r");

and the same for all your other multiple bursts of UART_TX(c).

 

BTW I renamed the function to mixed case. Don't use function names like UART_TX in all upper case as most programmers will expect that to be a macro not a function.

 

thank you so much

but I have a question. "\r" is for character number 10 or 13? what should I type for character 26?

...

Last Edited: Tue. Oct 24, 2017 - 09:02 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@sasan.riahi: you really don't need to quote the entire post!

 

Just enough to give context to what you're saying.

 

Alternatively, just press the 'Reply' button in the post to which you're replying - then the forum will automatically insert the reference

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

The two hex files look identical, so your chip is having it's flash programmed correctly by the TNM.

 

This leaves us with only two things to try that I can think of...

 

1) Fuses

2) Hardware

 

It seems unlikely that it's hardware as you say you can swap between ICE and TNM and the fault moves with the programmer that you use.

 

 

Ah, question...

 

when testing do you disconnect (ie unplug) the ICE and the TNM?

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

Example of quoting:

 

sasan.riahi wrote:
"\r" is for character number 10 or 13? what should I type for character 26?

Your 'C' textbook will have a list of these standard "escape sequences"

 

\r is CR - which is 13

 

26 is Ctrl-Z - there isn't a standard "escape sequence" for that.

 

EDIT

 

There are, of course, also plenty of online references; eg

 

http://en.cppreference.com/w/cpp/language/escape

 

https://en.wikipedia.org/wiki/Escape_sequences_in_C

 

http://blog.antronics.co.uk/2011/08/08/so-youre-thinking-of-starting-with-c/

Last Edited: Tue. Oct 24, 2017 - 09:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sasan.riahi wrote:
I found out something that it could cause the problem.. when programming is done, RESET pin in programmer is about 2.5v, since while programming it's between 0 and 5v. I tried to pull it up with 1k and 10k resistor, but it doesn't change, even a little!!

 

That is strange indeed. Why would reset be at mid rail, and apparently with low impedance? That shouldn't even possible in a logic output.

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

OK Thank youyes

...

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

El Tangas wrote:

That is strange indeed. Why would reset be at mid rail, and apparently with low impedance? That shouldn't even possible in a logic output.

 

A lot of universal programmers drive some pins with a DAC so that they can do high-voltage programming.

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

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

sasan.riahi wrote:
when programming is done, RESET pin in programmer is about 2.5v

Is that just with the TNM, or also with AtmlICE?

 

Makes Brian's question all the more pertinent:

Brian Fairchild wrote:
when testing do you disconnect (ie unplug) the ICE and the TNM?

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

awneil wrote:
Is that just with the TNM, or also with AtmlICE?

No it's just with TNM

 

Brian Fairchild wrote:
when testing do you disconnect (ie unplug) the ICE and the TNM?

as I told, when programming is done with TNM, reset pin goes to 2.5v ,so ATMEGA8 doesn't turn on while connector is connected.. 

when i'm programming with TNM, I unplug the connector but when programming with ATMEL ICE, it's connected and every thing is ok

 

...

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

I am afraid your ATTMEL ICE either gives you extra milliamps, or extra filtering....

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

It also works when ATMEL ICE is unpluged too! so all the power is supplied from my power supply

...

Last Edited: Tue. Oct 24, 2017 - 09:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

but I have a question. "\r" is for character number 10 or 13? what should I type for character 26?

(26) ==  16 +10 == x1A

"mystring\x1A" works...

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

awneil wrote:
26 is Ctrl-Z - there isn't a standard "escape sequence" for that.

That is to say, there isn't a specific sequence defined for it - but, as @dbrion0606 points out in #36, you can always use the \x... sequence to specify any arbitrary character code in hex.

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

I placed your function instead of mine and it's working great. But there is a warning here:

 

Severity Code Description Project File Line

Warning deprecated conversion from string constant to 'char*' [-Wwrite-strings] 

 

 

...

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

I tested it with x86-gcc version

$ gcc --version
gcc (GCC) 4.8.2

Perhaps your gcc is newer?

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

OK, so to be clear...

 

When you test with nothing connected the problem shows after you have programmed with the TNM but not when you have programmed with the ICE?

 

I think that leaves us with fuses.

 

 

 

Or, are we sure that the ICE is set to program the same hex file as the TNM?

'This forum helps those who help themselves.'

 

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  1. program using TNM
  2. power off
  3. disconnect TNM from target
  4. power-on target

 

Does it work?

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

sasan.riahi wrote:
Warning deprecated conversion from string constant to 'char*' [-Wwrite-strings] 

What if you make the function signature:

 

Uart_Tx_Str( const char * str )

?

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

awneil wrote:
What if you make the function signature:

 

It's ok now. No warning any more

...

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

After three days calling the company, finally I found the supporter and contact him..

Apparently theres a setup for reset pin, to be high or low or none: 
 

 

Every thing seems ok nowindecision

...

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

Lol, these small things you don't notice always get you cheeky

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

sasan.riahi wrote:
Every thing seems ok now

Great - so now please mark the solution: http://www.avrfreaks.net/comment...

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

Just to note that 26 (0x1A) is also 032 in octal so:

"test\032"

should also embed an ESC in this string. There is some argument to say it's better to use octal as an octal constant is 1, 2 or 3 digits and ends as soon as a character not in the range 0..7 is encountered. Hex constants (\xMMMMM) are a a little different as they contine for as many M that are in the range 0..9,a..f which can cause problems in, for example:

"\x1ABasically"

You may think this would encode 0x1A (ESC) and then the word "Basically" but that's not what happens. Both 'B' and 'A' are valid hex digits. The first invalid hex digit is the 's' so this is really the hex constant \x1ABA and then the word "sically". 1ABA won't fit in a "char" so it's the lower part (0xBA) that is eventually used and the 1A upper part is lost. To combat this some people use:

#define ESC_CHAR "x1A"

...

char text[] = "So " ESC_CHAR "Basically...";

C will "auto-concatenate" the three strings in this but the ESC will be just \x1A and will not "eat" the "Ba" at the start of "Basically". Using Octal this would have been:

char text[] = "So \032Basically...";

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

Note that 0x1A is EOF (Ctrl-Z) - not ESC.

 

ESC is 0x1B

 

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

This is my complete board schematic:

 

As pointed out, above, you need a lot of capacitors for your project to work correctly!

 

Read the 7805 data sheet for the details on the Cin and Cout caps.

 

The micro should have a 0.1 uF by-pass cap across Vcc and Ground, mounted close to the micro's pins.

 

AVcc should also be connected to VCC, and it should also have a 0.1 uF by-pass cap.

 

JC

 

Edit:

 

Maybe I should wake up before commenting on this, but what is the purpose of R2, R3, and R4?

 

Also, why did you put one current limiting resistor in the ground leg for each 7-segment display, instead of one resistor in the high side for each segment?

The issue is that the amount of current drawn by each 7-segment display depends upon how many segments are lit up.

That changes the current flowing through the resistor in the ground leg, and hence the voltage drop across it.

That changes the intensity of the display based upon how many segments are illuminated, and that is not generally what one wants.

 

JC

 

Last Edited: Tue. Oct 24, 2017 - 01:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You really don't need the 4511 chip--there are plenty of I/o lines ready for your use!

The 10 pin connection does not match the standard atmel isp 10 pin--is this correct?

When in the dark remember-the future looks brighter than ever.

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

This is small part of a bigger industrial project.

People who do not know about bypass caps and connecting a chip correctly should NOT work on such projects!

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Pages