AVR Xmega usart Receiver ISR is not working

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

Hi all,

im using atxmega128a4u controller, by polling method my system receive bytes, but  when im using ISR did'nt receive interrupt.

What i do?

Here my code, Help me...

#include <avr/io.h>
#include<avr/interrupt.h>
#include<util/delay.h>
unsigned int i=0,clocktick=0,tick=0,a=0;
unsigned char rx_data;
unsigned long int AvgVoltage=0;
int main()
{
	System_init();
	uart_init();
	while(1)
	{
	    uart1_out(rx_data);		
	}
}
void uart_init(void)
{
	PORTD_DIR		    |= 0x80;					// TXD0-PD7 as output, RXD-PD6 as input
	PORTD_OUTSET		= 0x80;					// TXD0-PD3 IS Must be HIGH while initially
	USARTD1_STATUS		= 0x80;					// Flags are zero
	USARTD1_CTRLA		= 0x3C;					// High Priority for Interrupts
	USARTD1_CTRLB		= 0x18;					// Set the Transmitter Enable and Receiver Enable(if only transmitter put 0x08)
	USARTD1_CTRLC		= 0x03;					// Asynchronous Mode, NO Parity, 1 stop bit and 8 bit data
	USARTD1_BAUDCTRLA	= 0x19;					// BSEL value is 25, by 9600 baud rate for 4MHZ frequency with considered BSCALE as 0.
	USARTD1_BAUDCTRLB	= 0x00;					// BSCALE is 0 and BSEL upper bits 0.
	SREG |= 0x80;								// Global Interrupt Enable 
	
}
void uart1_out(unsigned char data_tx)
{
	USARTD1_DATA = data_tx;						// Put data to DATA register
	while(!((USARTD1_STATUS & 0x20)==0x20));	// Check the bit whether the data is sent or not
}

ISR(USARTD1_RXC_vect)					// USART D1 Receiver interrupt Routine
{
	rx_data = USARTD1_DATA;		
	StatusLED_TOGL;
}

 

makcontrols

Last Edited: Mon. Jun 5, 2017 - 09:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you set High Level Interrupt Enable in PMIC setting?
Are you running sei ()?

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

Yes, i have Set High level interrupt, both TX and RX

USARTD1_CTRLA		= 0x3C;					// High Priority for Interrupts
SREG |= 0x80;								// Global Interrupt Enable 

 

 

makcontrols

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

wrong.
I asked if I set "PMIC" (Programmable Multilevel Interrupt Controller).

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

kabasan wrote:

wrong.
I asked if I set "PMIC" (Programmable Multilevel Interrupt Controller).

Yes I have Set High level Interrupt, by CTRLA Register.

 

Attachment(s): 

makcontrols

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

Does the following code somewhere in your source exist?
PMIC.CTRL = PMIC_HILVLEX_bm;

Attachment(s): 

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

kabasan wrote:

Does the following code somewhere in your source exist?
PMIC.CTRL = PMIC_HILVLEX_bm;

Yes. I enabled.

PMIC_CTRL |= 0x07;						// Activating the High Medium Low level Interrupts in the Controller
SREG |= 0x80;								// Global Interrupt Enable 
	

 

makcontrols

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

Why on earth do you program with hard coded numbers like 0x07? Kabasan has already showed you that there are symbolic names for such bit patterns like PMIC_HILVLEX_bm. In fact when you look at an Xmega device header you find:

iox128a4u.h:#define PMIC_HILVLEX_bm  0x04  /* High Level Interrupt Executing bit mask. */
iox128a4u.h:#define PMIC_HILVLEX_bp  2  /* High Level Interrupt Executing bit position. */
iox128a4u.h:#define PMIC_MEDLVLEX_bm  0x02  /* Medium Level Interrupt Executing bit mask. */
iox128a4u.h:#define PMIC_MEDLVLEX_bp  1  /* Medium Level Interrupt Executing bit position. */
iox128a4u.h:#define PMIC_LOLVLEX_bm  0x01  /* Low Level Interrupt Executing bit mask. */
iox128a4u.h:#define PMIC_LOLVLEX_bp  0  /* Low Level Interrupt Executing bit position. */

So your 0x07 value appears to be all of HI, MED and LO and the same time?!? Surely that is an error?

 

Your code actually says:

PMIC_CTRL |= 0x07;						// Activating the High Medium Low level Interrupts in the Controller

so if the comment is right that suggests it is the MED one you want to use? That is 0x02 not 0x07. So either:

PMIC_CTRL |= 0x02;

but surely it is far better to write:

PMIC_CTRL |= PMIC_MEDLVLEX_bm;

which avoids errors such as using 0x07 when you meant 0x02. Similarly here:

	USARTD1_STATUS		= 0x80;
	USARTD1_CTRLA		= 0x3C;
	USARTD1_CTRLB		= 0x18;
	USARTD1_CTRLC		= 0x03;

replace those "magic numbers" with the names of the signals you are actually setting here.

 

Oh and in avr-gcc don't use:

	SREG |= 0x80;								// Global Interrupt Enable 

The <avr/interrupt.h> header contains:

	sei();								// Global Interrupt Enable 

which will insert the single "SEI" opcode that achieves the setting of bit 7 in SREG.

Last Edited: Mon. Jun 5, 2017 - 08:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Infinite loop of transmission is a problem.
If there is no received data please stop sending.

Last Edited: Mon. Jun 5, 2017 - 09:05 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actully ,Im not familier with ATMEL controller because of im new to this one.

 

is there any Problem with using that numbers instead of the lib. keywords? 

 

So your 0x07 value appears to be all of HI, MED and LO and the same time?!? Surely that is an error?

im using 2 uart with different interrupt priority, so  i need to set priority level by initially. that is why i choose.

 

 

makcontrols

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

At USARTE0 of atxmega16a4u (I think the same for USARTC1)

I confirmed normal operation by doing main () below.

 

int main(){
    PMIC.CTRL = PMIC_HILVLEX_bm;
    uart_init();
    while(1) {
        uart1_out(rx_data);
    }
}

 

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

Prabhu R wrote:

Hi all,

im using atxmega128a4u controller, by polling method my system receive bytes, but  when im using ISR did'nt receive interrupt.

What i do?

Here my code, Help me...

#include <avr/io.h>
#include<avr/interrupt.h>
#include<util/delay.h>
unsigned int i=0,clocktick=0,tick=0,a=0;
unsigned char rx_data;
unsigned long int AvgVoltage=0;
int main()
{
	System_init();
	uart_init();
	while(1)
	{
	    uart1_out(rx_data);		
	}
}
void uart_init(void)
{
	PORTD_DIR		    |= 0x80;					// TXD0-PD7 as output, RXD-PD6 as input
	PORTD_OUTSET		= 0x80;					// TXD0-PD3 IS Must be HIGH while initially
	USARTD1_STATUS		= 0x80;					// Flags are zero
	USARTD1_CTRLA		= 0x3C;					// High Priority for Interrupts
	USARTD1_CTRLB		= 0x18;					// Set the Transmitter Enable and Receiver Enable(if only transmitter put 0x08)
	USARTD1_CTRLC		= 0x03;					// Asynchronous Mode, NO Parity, 1 stop bit and 8 bit data
	USARTD1_BAUDCTRLA	= 0x19;					// BSEL value is 25, by 9600 baud rate for 4MHZ frequency with considered BSCALE as 0.
	USARTD1_BAUDCTRLB	= 0x00;					// BSCALE is 0 and BSEL upper bits 0.
	SREG |= 0x80;								// Global Interrupt Enable 
	
}
void uart1_out(unsigned char data_tx)
{
	USARTD1_DATA = data_tx;						// Put data to DATA register
	while(!((USARTD1_STATUS & 0x20)==0x20));	// Check the bit whether the data is sent or not
}

ISR(USARTD1_RXC_vect)					// USART D1 Receiver interrupt Routine
{
	rx_data = USARTD1_DATA;		
	StatusLED_TOGL;
}

 

Dear Kabasan,

i have used PMIC interrupt priority as high but i forgot update this forum.

and also i make while loop is empty. Even LED also didnt toggle. I dont receive any interrupt. so only i confused. by polling its working great.

 

and 

makcontrols

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

I must be going blind - you appear to be using a macro there that is not actually defined in any of the preceding lines?

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

Dear Clawson,

See, my code is too length. so i just put over there my doubt part only. i defined StatusLED_TOGGLE but i didnt post those all macros.

 

i got result from ADC, DAC, GPIOs and UART Transmitting. So i have doubt in receiver part only.

 

makcontrols

Last Edited: Mon. Jun 5, 2017 - 09:35 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I doubt System_init.
Please replace it as I posted
PMIC.CTRL = PMIC_HILVLEX_bm;

Since the system clock becomes 8 MHz, it will be 19200 bps, but I think that it will work normally.

Make sure that the watchdog timer is not enabled.

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

Your code is enabling the TXC interrupt. Do you have ISR(USARTD1_TXC_vect) defined? The default compiler behavior is to execute the reset vector for undefined ISRs. The code you've share will transmit a byte, reset, transmit a byte, reset, transmit a byte.... Since it appears you're debugging via blinkenlights, toggle the LED at the beginning of main() to see if this is happening in your full code.

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

Here is my full code,

/************************************************************************/
/*						HEADERS DECLARATIONS                            */
/************************************************************************/
#include <avr/io.h>
#include<avr/interrupt.h>
#include<util/delay.h>
#include <stdbool.h>
#include "uart.h"
#define FCPU 4e6

/************************************************************************

						GPIO CONTROL DEFINITION                  
						       
************************************************************************/

#define StatusLED_ON	(PORTE_OUTCLR = 0x02)		// Status LED pin at PE1
#define StatusLED_OFF	(PORTE_OUTSET = 0x02)
#define StatusLED_TOGL	(PORTE_OUTTGL = 0x02)
#define RS485_Enable	(PORTE_OUTCLR = 0x04)		// RS485 Enable and Disable pin at PE2
#define RS485_Disable	(PORTE_OUTSET = 0x04)
#define D1OUT_ON		(PORTC_OUTSET = 0x10)		// Digital Out/LED pin at PC4
#define D1OUT_OFF		(PORTC_OUTCLR = 0x10)
#define D1OUT_TOGL		(PORTC_OUTTGL = 0x10)
#define D2OUT_ON		(PORTD_OUTSET = 0x10)		// Digital Out/LED pin at PD4
#define D2OUT_OFF		(PORTD_OUTCLR = 0x10)
#define D2OUT_TOGL		(PORTD_OUTTGL = 0x10)
#define D3OUT_ON		(PORTD_OUTSET = 0x20)		// Digital Out/LED pin at PD5
#define D3OUT_OFF		(PORTD_OUTCLR = 0x20)
#define D3OUT_TOGL		(PORTD_OUTTGL = 0x20)
#define D4OUT_ON		(PORTD_OUTSET = 0x02)		// Digital Out/LED pin at PD1
#define D4OUT_OFF		(PORTD_OUTCLR = 0x02)
#define D4OUT_TOGL		(PORTD_OUTTGL = 0x02)
#define DAC1_REF_DATA_CH0	((2.5*4095)/3.3)		// DAC_DATA=((VDAC output * 12bit resolution)/VRef)
// MODBUS
#define SlaveAddr		0x01
#define FunctionCode	0x03

/************************************************************************

						FUNCTIONS DECLARATIONS                         
						 
************************************************************************/
void System_init(void);								// System initilization
void VT100_Setting(void);							// VT100 terminal format
void Get_ADC(void);									// Get the ADC voltage
void usart_rx(void);								// 
void GetRegisterData(void);

/************************************************************************

						VARIABLE DECLARATIONS                          
						
************************************************************************/
unsigned int i=0,clocktick=0,tick=0,a=0,temp=0, ModArray[40];
unsigned char rx_data;
unsigned long int AvgVoltage=0;
//typedef enum {false1 = 0, true1 = 1} myenum;

/************************************************************************

						MAIN FUNCTION ROUTINE                          
						
************************************************************************/
int main()
{
	System_init();
	StatusLED_OFF;
	while(1)
	{
		u1htd3(temp);
		uart1_out(0x0a); uart1_out(0x0d);
		_delay_ms(500);_delay_ms(500);
	}
}

void GetRegisterData()
{
	ModArray[0] = SlaveAddr;
	ModArray[1] = FunctionCode;
	ModArray[2] = 0x00;
	ModArray[3] = 0x05;
	ModArray[4] = 0x00;
	ModArray[5] = 0x03;
//	ModArray[6] = crc(*ModArray,6);
	for (i=0; i<=5; i++)
	{
		uart1_out(ModArray[i]);
	}
}
void usart_rx()
{
	while(!(USARTD1_STATUS & USART_RXCIF_bm));
	char ch = USARTD1_DATA;
	StatusLED_TOGL;
	uart1_out(ch);
}
/************************************************************************

						SYSTEM INITIALIZATION
						
************************************************************************/
void System_init(void)
{
	PORTE_DIR |= 0b00000110;			// PE1 is Status LED and PE2 is RS485 Enable both act as output
	PORTD_DIR |= 0b00110010;			// I/O LED
	PORTC_DIR |= 0b00010000;			// LED
	PORTB_DIR |= 0b00000100;			// PB2 (DAC) as output
	uart_init();						// uart initialization
	RS485_Enable;						// Enable the RS485 pin
	
/*-----------------------------------------------------------------------------------
								ADC Initialization				
-----------------------------------------------------------------------------------*/
	PORTA_DIR |= 0x00;					// PORTA act as input
	PORTB_DIR |= 0b00000100;			// PB2 as output, for ADC reference
	//Registers
	ADCA_CTRLA		= 0x01;				//DMA off,Conversion disable, Flush off
	ADCA_CTRLB		= 0x00;				//High impedance, Current NO limit, 12Bit
	ADCA_REFCTRL	= 0x20;				//PortA AREFA, No band gap, No temp. measurement
	ADCA_PRESCALER	= 0x03;				// Prescalar is DIV32
	//Channel
	ADCA_CH0_CTRL	= 0x00;				//Do not ADC conversion, gain as 1
	ADCA_CH0_MUXCTRL= 0x28;				//Mux configured to Channel ADC5 (i.e.) PA5
	ADCA_CH0_INTCTRL= 0x00;				//interrupt When conversion is complete
	
/*-----------------------------------------------------------------------------------
								DAC-Channel 0  Initialization				
-----------------------------------------------------------------------------------*/
	DACB_CTRLA		= 0x05;				// CHO channel enable, DAC ON
	DACB_CTRLB		= 0x00;				// Single channel operation CH0 , No Event trigger used
	DACB_CTRLC		= 0x08;				// Reference as VCC
	DACB_EVCTRL		= 0x00;				// No trigger used
	DACB_CH0DATA	= DAC1_REF_DATA_CH0;// Put DAC data, (i.e) 2.5V output
/*-----------------------------------------------------------------------------------
							TIMER Initialization				
-----------------------------------------------------------------------------------*/	
	TCC0_CTRLA		= 0x06;				// Prescalar as 256
	TCC0_CTRLB		= 0x00;
	TCC0_INTCTRLA	= 0x03;				// Over or underflow interrupt level High priority and Disabled the Timer error interrupt
	TCC0_INTFLAGS	= 0x01;				// Clear the interrupt
	TCC0_PER		= 78;				// Clock tick 10ms (i.e)F=1/10ms=200Hz,
										// Time Count = (Fosc/(Prescale*Interrupt Frequency))-1 ==> (4000000/256*200)-1 = 77.125
/*-----------------------------------------------------------------------------------
		Global Interrupt and Programmable Multilevel Interrupt Controller(PMIC)
-----------------------------------------------------------------------------------*/
	PMIC_CTRL|=PMIC_HILVLEN_bm|PMIC_MEDLVLEN_bm|PMIC_LOLVLEN_bm;// Activating the High Medium Low level Interrupts in the Controller
	SREG|=0x80;							//Global interrupt enable register
}

/************************************************************************

							GET ADC DATA			                 
							   
/************************************************************************/
void Get_ADC()
{
	AvgVoltage = 0;
	for(i=0; i<500; i++)
	{
		ADCA_CTRLA		|=	0x08;			// Channel start the single conversion, after it will automatically reset
		ADCA_CH0_CTRL	 =	0x81;			// Start conversion and Single ended input
		while(!(ADCA_INTFLAGS & 0x01));		// Wait until conversion is complete
		AvgVoltage += ADCA_CH0_RES;			// Load the 12 bit value
	}
	_delay_ms(500);
	AvgVoltage = AvgVoltage/500;			// get Average of 500 Samples
	uart1_out(27); uart1_con_out("[4;15H"); u1htd4(AvgVoltage);
}

void VT100_Setting()
{
		uart1_out(27); uart1_con_out("[1;1H-------------------------------");	
		uart1_out(27); uart1_con_out("[2;10HMWM TESTING");
		uart1_out(27); uart1_con_out("[3;1H-------------------------------");	
		uart1_out(27); uart1_con_out("[4;1HADC COUNT   -");
		uart1_out(27); uart1_con_out("[5;1HTIMER COUNT -");
		
}
ISR(USARTD1_RXC_vect)					// USART D1 Receiver interrupt Routine
{
	rx_data = USARTD1_DATA;		
	temp++;
}

//ISR(TCC0_OVF_vect)						// Timer C0 Interrupt Routine
//{
	//tick++;
	//if(tick == 50){StatusLED_TOGL;}
//}

Uart.h file is

#define true 1
#define false 0

void uart_init(void);
void uart1_out(unsigned char);
void uart1_con_out(unsigned char *);
void delay_sec(unsigned int);
void u1htd2(unsigned int);
void u1htd3(unsigned int);
void u1htd4(unsigned int);


bool usart_set_baudrate(USART_t *usart, uint32_t baud, uint32_t cpu_hz);

void uart_init(void)
{
	/////////// MCU UART   ///////////////////////////////////////////////////////////////
	PORTD_DIR			|= 0x80;					// TXD0-PD7 as output, RXD-PD6 as input
	PORTD_OUTSET		 = 0x80;					// TXD0-PD3 IS Must be HIGH while initially
	
	USARTD1_STATUS		= 0x80;					// Flags are zero
	USARTD1_CTRLA		= 0x3C;					// High Priority for Interrupts
	USARTD1_CTRLB		= 0x18;					// Set the Transmitter Enable and Receiver Enable(if only transmitter put 0x08)
	USARTD1_CTRLC		= 0x03;					// Asynchronous Mode, NO Parity, 1 stop bit and 8 bit data
	//USARTD1_BAUDCTRLA	= 0x19;					// BSEL value is 25, by 9600 baud rate for 4MHZ frequency with considered BSCALE as 0.
	//USARTD1_BAUDCTRLB	= 0x00;					// BSCALE is 0 and BSEL upper bits 0.
	usart_set_baudrate(&USARTD1,9600, 4000000);	// Setting the baud rate to high level 9600
	
}
void uart1_out(unsigned char data_tx)
{
	USARTD1_DATA = data_tx;						// Put data to DATA register
	while(!((USARTD1_STATUS & 0x20)==0x20));	// Check the bit whether the data is sent or not
}
void uart1_con_out(unsigned char *data_con_tx)
{
	while(*data_con_tx)
	{
		uart1_out(*data_con_tx++);
	}
}

void u1htd2(unsigned int hexdata2)			// 57
{
	unsigned int b_data,c_data;
	b_data = hexdata2/10;					// b_data  = 57/10 = 5
	hexdata2 = hexdata2%10;					// hexdata = 57%10 = 7
	c_data = hexdata2;						// c_data  = 5
	uart1_out(b_data + '0');
	uart1_out(c_data + '0');	
}
void u1htd3(unsigned int hexdata3)			// 125
{
	unsigned int a_data,b_data,c_data;
	a_data = hexdata3/100;					// a_data  = 125/100 = 1
	hexdata3 = hexdata3%100;				// hexdata = 125%100 = 25
	b_data = hexdata3/10;					// b_data  = 25/10 = 2
	hexdata3 = hexdata3%10;					// hexdata = 25%10 = 5	
	c_data = hexdata3;						// c_data  = 5
	uart1_out(a_data + '0');
	uart1_out(b_data + '0');
	uart1_out(c_data + '0');
}
void u1htd4(unsigned int hexdata4)			// 1257
{
	unsigned int a_data,b_data,c_data,d_data;
	d_data	 = hexdata4/1000;				// d_data  = 1257/1000 = 1
	hexdata4 = hexdata4%1000;				// d_data  = 1257%1000 = 257
	a_data = hexdata4/100;					// a_data  = 257/100 = 2
	hexdata4 = hexdata4%100;				// hexdata = 257%100 = 57
	b_data = hexdata4/10;					// b_data  = 57/10 = 5
	hexdata4 = hexdata4%10;					// hexdata = 57%10 = 7
	c_data = hexdata4;						// c_data  = 5
	uart1_out(d_data + '0');
	uart1_out(a_data + '0');
	uart1_out(b_data + '0');
	uart1_out(c_data + '0');
}

bool usart_set_baudrate(USART_t *usart, uint32_t baud, uint32_t cpu_hz)
{
	int8_t exp;
	uint32_t div;
	uint32_t limit;
	uint32_t ratio;
	uint32_t min_rate;
	uint32_t max_rate;
	baud = baud*2;
	/*
	 * Check if the hardware supports the given baud rate
	 */
	/* 8 = (2^0) * 8 * (2^0) = (2^BSCALE_MIN) * 8 * (BSEL_MIN) */
	max_rate = cpu_hz / 8;
	/* 4194304 = (2^7) * 8 * (2^12) = (2^BSCALE_MAX) * 8 * (BSEL_MAX+1) */
	min_rate = cpu_hz / 4194304;

	if (!((usart)->CTRLB & USART_CLK2X_bm)) {
		max_rate /= 2;
		min_rate /= 2;
	}

	if ((baud > max_rate) || (baud < min_rate)) {
		return false;
	}

	/* Check if double speed is enabled. */
	if (!((usart)->CTRLB & USART_CLK2X_bm)) {
		baud *= 2;
	}

	/* Find the lowest possible exponent. */
	limit = 0xfffU >> 4;
	ratio = cpu_hz / baud;

	for (exp = -7; exp < 7; exp++) {
		if (ratio < limit) {
			break;
		}

		limit <<= 1;

		if (exp < -3) {
			limit |= 1;
		}
	}

	/*
	 * Depending on the value of exp, scale either the input frequency or
	 * the target baud rate. By always scaling upwards, we never introduce
	 * any additional inaccuracy.
	 *
	 * We are including the final divide-by-8 (aka. right-shift-by-3) in
	 * this operation as it ensures that we never exceeed 2**32 at any
	 * point.
	 *
	 * The formula for calculating BSEL is slightly different when exp is
	 * negative than it is when exp is positive.
	 */
	if (exp < 0) {
		/* We are supposed to subtract 1, then apply BSCALE. We want to
		 * apply BSCALE first, so we need to turn everything inside the
		 * parenthesis into a single fractional expression.
		 */
		cpu_hz -= 8 * baud;

		/* If we end up with a left-shift after taking the final
		 * divide-by-8 into account, do the shift before the divide.
		 * Otherwise, left-shift the denominator instead (effectively
		 * resulting in an overall right shift.)
		 */
		if (exp <= -3) {
			div = ((cpu_hz << (-exp - 3)) + baud / 2) / baud;
		} else {
			baud <<= exp + 3;
			div = (cpu_hz + baud / 2) / baud;
		}
	} else {
		/* We will always do a right shift in this case, but we need to
		 * shift three extra positions because of the divide-by-8.
		 */
		baud <<= exp + 3;
		div = (cpu_hz + baud / 2) / baud - 1;
	}

	(usart)->BAUDCTRLB = (uint8_t)(((div >> 8) & 0X0F) | (exp << 4));
	(usart)->BAUDCTRLA = (uint8_t)div;

	return true;
}

 

makcontrols

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

Anything Wants to change in my code, to get and complete Usart ISR ?

makcontrols

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

Uart.h file is

That looks like a Uart.c file rather than a header file.

 

Did you do anything about this? http://www.avrfreaks.net/comment... it doesn't look like.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly