Commit 11fb15c0 authored by medlem's avatar medlem

Working USART and fixed comments and defines and tx string

parent 10bf504f
Pipeline #242 failed with stages
......@@ -7,13 +7,20 @@
:100060000C945A000C945A000C945A000C945A00A8
:100070000C945A000C945A000C945A000C945A0098
:100080000C945A000C945A000C945A000C945A0088
:100090000C945A000C945A000C945A000C945A0078
:1000A00011241FBECFEFCDBFDFE3DEBF0E9476007D
:1000B0000C9488000C940000E0E2F4E021E0258339
:100090000C945A000C945A000C949B000C945A0037
:1000A00011241FBECFEFCDBFDFE3DEBF0E9488006B
:1000B0000C94B2000C940000E0E2F4E021E025830F
:1000C0002183E0E6F8E06087BB27A92F982F872FD0
:1000D000818783E0878380EC86830895E0E6F8E0FB
:1000E000948195FFFDCF8093620808956CE675E0DA
:1000F00080E090E00E945C00789488E60E946E00A8
:1001000025ED88E092E0215080409040E1F7F5CF66
:04011000F894FFCF91
:1000D000818783E0878380EC868385818068858340
:1000E0000895E0E6F8E0948195FFFDCF80936208E3
:1000F0000895CF93DF93EC018881882331F0219616
:100100000E94710089918111FBCFDF91CF910895F9
:100110006CE675E080E090E00E945C00789488E6F0
:1001200091E40E94790025ED88E092E02150804022
:100130009040E1F7F4CF1F920F920FB60F92112467
:100140008F93EF93FF93E0E6F8E084818823ECF748
:1001500080916008FF91EF918F910F900FBE0F90EB
:080160001F901895F894FFCFE1
:10016800446574746520657220656E2074657374C7
:020178000A007B
:00000001FF
This diff is collapsed.
......@@ -153,7 +153,7 @@ END GROUP
.rela.plt
*(.rela.plt)
.text 0x00000000 0x114
.text 0x00000000 0x168
*(.vectors)
.vectors 0x00000000 0xa0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o
0x00000000 __vector_default
......@@ -208,7 +208,6 @@ END GROUP
*(.init9)
*(.text)
.text 0x000000b4 0x4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o
0x000000b4 __vector_38
0x000000b4 __vector_22
0x000000b4 __vector_28
0x000000b4 __vector_1
......@@ -251,18 +250,24 @@ END GROUP
0x000000b8 . = ALIGN (0x2)
*(.text.*)
.text.uart_init
0x000000b8 0x24 UART-LF.o
0x000000b8 0x2a UART-LF.o
0x000000b8 uart_init
.text.uart_transmit
0x000000dc 0x10 UART-LF.o
0x000000dc uart_transmit
.text.main 0x000000ec 0x24 UART-LF.o
0x000000ec main
0x00000110 . = ALIGN (0x2)
0x000000e2 0x10 UART-LF.o
0x000000e2 uart_transmit
.text.uart_transmit_string
0x000000f2 0x1e UART-LF.o
0x000000f2 uart_transmit_string
.text.main 0x00000110 0x26 UART-LF.o
0x00000110 main
.text.__vector_38
0x00000136 0x2e UART-LF.o
0x00000136 __vector_38
0x00000164 . = ALIGN (0x2)
*(.fini9)
.fini9 0x00000110 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o)
0x00000110 _exit
0x00000110 exit
.fini9 0x00000164 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o)
0x00000164 _exit
0x00000164 exit
*(.fini9)
*(.fini8)
*(.fini8)
......@@ -281,16 +286,18 @@ END GROUP
*(.fini1)
*(.fini1)
*(.fini0)
.fini0 0x00000110 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o)
.fini0 0x00000164 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o)
*(.fini0)
0x00000114 _etext = .
0x00000168 _etext = .
.rodata
.rodata 0x00004168 0x12 load address 0x00000168
*(.rodata)
*(.rodata*)
.rodata.str1.1
0x00004168 0x12 UART-LF.o
*(.gnu.linkonce.r*)
.data 0x00802800 0x0 load address 0x00000114
.data 0x00802800 0x0 load address 0x0000017a
[!provide] PROVIDE (__data_start, .)
*(.data)
*(.data*)
......@@ -305,8 +312,8 @@ END GROUP
*(.bss*)
*(COMMON)
[!provide] PROVIDE (__bss_end, .)
0x00000114 __data_load_start = LOADADDR (.data)
0x00000114 __data_load_end = (__data_load_start + SIZEOF (.data))
0x0000017a __data_load_start = LOADADDR (.data)
0x0000017a __data_load_end = (__data_load_start + SIZEOF (.data))
.noinit 0x00802800 0x0
[!provide] PROVIDE (__noinit_start, .)
......@@ -377,41 +384,42 @@ END GROUP
.debug_sfnames
*(.debug_sfnames)
.debug_aranges 0x00000000 0x30
.debug_aranges 0x00000000 0x40
*(.debug_aranges)
.debug_aranges
0x00000000 0x30 UART-LF.o
0x00000000 0x40 UART-LF.o
.debug_pubnames
*(.debug_pubnames)
.debug_info 0x00000000 0x27ba
.debug_info 0x00000000 0x2823
*(.debug_info .gnu.linkonce.wi.*)
.debug_info 0x00000000 0x22b7 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o
.debug_info 0x000022b7 0x503 UART-LF.o
.debug_info 0x000022b7 0x56c UART-LF.o
.debug_abbrev 0x00000000 0x226c
.debug_abbrev 0x00000000 0x22d2
*(.debug_abbrev)
.debug_abbrev 0x00000000 0x20e0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o
.debug_abbrev 0x000020e0 0x18c UART-LF.o
.debug_abbrev 0x000020e0 0x1f2 UART-LF.o
.debug_line 0x00000000 0x36a
.debug_line 0x00000000 0x3c8
*(.debug_line .debug_line.* .debug_line_end)
.debug_line 0x00000000 0x187 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o
.debug_line 0x00000187 0x1e3 UART-LF.o
.debug_line 0x00000187 0x241 UART-LF.o
.debug_frame 0x00000000 0x44
.debug_frame 0x00000000 0x8c
*(.debug_frame)
.debug_frame 0x00000000 0x44 UART-LF.o
.debug_frame 0x00000000 0x8c UART-LF.o
.debug_str 0x00000000 0x11f0
.debug_str 0x00000000 0x1211
*(.debug_str)
.debug_str 0x00000000 0xe5d C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o
.debug_str 0x00000e5d 0x393 UART-LF.o
0x3cc (size before relaxing)
.debug_str 0x00000e5d 0x3b4 UART-LF.o
0x3ed (size before relaxing)
.debug_loc
.debug_loc 0x00000000 0xd7
*(.debug_loc)
.debug_loc 0x00000000 0xd7 UART-LF.o
.debug_macinfo
*(.debug_macinfo)
......@@ -431,9 +439,9 @@ END GROUP
.debug_pubtypes
*(.debug_pubtypes)
.debug_ranges 0x00000000 0x20
.debug_ranges 0x00000000 0x30
*(.debug_ranges)
.debug_ranges 0x00000000 0x20 UART-LF.o
.debug_ranges 0x00000000 0x30 UART-LF.o
.debug_macro
*(.debug_macro)
......
......@@ -8,13 +8,20 @@ S11300500C945A000C945A000C945A000C945A00B4
S11300600C945A000C945A000C945A000C945A00A4
S11300700C945A000C945A000C945A000C945A0094
S11300800C945A000C945A000C945A000C945A0084
S11300900C945A000C945A000C945A000C945A0074
S11300A011241FBECFEFCDBFDFE3DEBF0E94760079
S11300B00C9488000C940000E0E2F4E021E0258335
S11300900C945A000C945A000C949B000C945A0033
S11300A011241FBECFEFCDBFDFE3DEBF0E94880067
S11300B00C94B2000C940000E0E2F4E021E025830B
S11300C02183E0E6F8E06087BB27A92F982F872FCC
S11300D0818783E0878380EC86830895E0E6F8E0F7
S11300E0948195FFFDCF8093620808956CE675E0D6
S11300F080E090E00E945C00789488E60E946E00A4
S113010025ED88E092E0215080409040E1F7F5CF62
S1070110F894FFCF8D
S11300D0818783E0878380EC86838581806885833C
S11300E00895E0E6F8E0948195FFFDCF80936208DF
S11300F00895CF93DF93EC018881882331F0219612
S11301000E94710089918111FBCFDF91CF910895F5
S11301106CE675E080E090E00E945C00789488E6EC
S113012091E40E94790025ED88E092E0215080401E
S11301309040E1F7F4CF1F920F920FB60F92112463
S11301408F93EF93FF93E0E6F8E084818823ECF744
S113015080916008FF91EF918F910F900FBE0F90E7
S10B01601F901895F894FFCFDD
S1130168446574746520657220656E2074657374C3
S10501780A0077
S9030000FC
......@@ -15,33 +15,33 @@
/*
In this exercise we will set up and use UART communication.
The embedded debugger has a virtual com port that we will use to communicate with the computer.
*/
*/
#define TX_PORT PORTB
#define TX_PIN 0
void uart_init(unsigned long baud){
//From chapter 24.3 in datasheet
//From chapter 22.3.1 in datasheet
PORTB.OUTSET = (1 << 0); //Setting up TX pin as output
PORTB.DIRSET = (1 << 0); //Setting up TX pin as output
TX_PORT.OUTSET = (1 << TX_PIN); //Setting up TX pin as output
TX_PORT.DIRSET = (1 << TX_PIN); //Setting up TX pin as output
//USART3.BAUDH = (baud >> 8); //Shift register right by 8 bits to get the 8 high bits
//USART3.BAUDL = baud; //Set baud rate without shifting to get the 8 low bits
//It turns out the compiler can handle this automatically, meaning this works just as well:
USART3.BAUDL = (uint8_t)baud;
USART3.BAUDH = (uint8_t)(baud >> 8);
//Set baud rate register
USART3.BAUDL = (uint8_t) baud; //Set baud rate without shifting to get the 8 low bits
USART3.BAUDH = (uint8_t)(baud >> 8); //Shift register right by 8 bits to get the 8 high bits
//USART.CTRLC CMODE bits default to async, 1 stop bit, 8 bit character size
USART3.CTRLC = (0x3 << 0);
//Since all bits are default 0 we only need to change the character size part
USART3.CTRLC = (0x3 << USART_CHSIZE0_bp);
USART3.CTRLB = (1 << USART_RXEN_bp) | (1 << USART_TXEN_bp); //Enable RX and TX
//Enable RX and TX
USART3.CTRLB = (1 << USART_RXEN_bp) | (1 << USART_TXEN_bp);
//USART3.CTRLA |= (1 << USART_RXCIE_bp); //Enable interrupts on incoming data
//Enable interrupts on incoming data
USART3.CTRLA |= (1 << USART_RXCIE_bp);
}
// function to transmit data
......@@ -55,11 +55,20 @@ void uart_transmit(char data){
//wait for previous transmit to finish
};
//Put our new data into se sending register
//Put our new data into tx data register
USART3.TXDATAL = data;
}
//To send a string we can do this
void uart_transmit_string(char* data) {
while (*data != '\0') {
uart_transmit(*data);
data++;
}
}
int main(void)
{
//Initialize the UART with our function.
......@@ -72,10 +81,21 @@ int main(void)
{
//We don't really need to do anything here.
//the ISR will handle receiving.
uart_transmit('h');
uart_transmit_string("Dette er en test\n");
_delay_ms(200);
}
}
//Interrupt service routine for the receiver.
ISR (USART3_RXC_vect) {
//In the interrupt we will read the data in the receive buffer
//First we should check that new data has arrived the receive buffer
while (!(USART3.STATUS & (1 << USART_RXCIF_bp))){
//wait for previous transmit to finish
};
//Store the data in a temporarily variable
uint8_t tmp = USART3.RXDATAL;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment