die RS232 Übertragung läuft Problemlos, habe dazu folgenden Code (per
polling):
USART_PORT.DIRSET = PIN3_bm; // Pin 3 (TXD0) as output.
USART_PORT.DIRCLR = PIN2_bm; // Pin 2 (RXD0) as input.
// USARTD0, 8 Data bits, No Parity, 1 Stop bit
USART.CTRLC = (uint8_t) USART_CHSIZE_8BIT_gc | USART_PMODE_DISABLED_gc |
false;
/* Target: Internal RC 2MHz (default)
* Example (9600bps) : - I/O clock = 2MHz
* - 9600bps can be acheived by 9600bps / 2^0
* - UBRR = 2MHz/(16*9600)-1 = 12.02
* - ScaleFactor = 0
*/
USART.BAUDCTRLA = BSEL_VALUE;
// Enable both RX and TX
USART.CTRLB |= USART_RXEN_bm;
USART.CTRLB |= USART_TXEN_bm;
char cs_Taste1[TEST_CHARS] = "Text1";
for (uint8_t i = 0;i<TEST_CHARS;i++)
{
USART.DATA = cs_Taste1[i];
for (uint8_t k =0; k<200;k++);
}
************************************************************************
*****************************
bzw. mit interrupt sieht dann die einbindung so aus...:
// PD3 (TX) as output
USARTPORT.DIRSET = PIN3_bm;
// PD2 (RX) as input
USARTPORT.DIRCLR = PIN2_bm;
// Use USARTD0 and initialize buffers
USART_InterruptDriver_Initialize(&USART_data, &USART,
USART_DREINTLVL_LO_gc);
// USARTD0, 8 Data bits, No Parity, 1 Stop bit
USART_Format_Set(USART_data.usart, USART_CHSIZE_8BIT_gc,
USART_PMODE_DISABLED_gc, false);
// Enable RXC interrupt
USART_RxdInterruptLevel_Set(USART_data.usart, USART_RXCINTLVL_LO_gc);
// Set Baudrate to 9600 bps:
// Use the default I/O clock frequency that is 2 MHz.
// Do not use the baudrate scale factor
//
// Baudrate select = (1/(16*(((I/O clock frequency)/Baudrate)-1)
// = 12
USART_Baudrate_Set(&USART, 12 , 0);
/* Enable both RX and TX. */
USART_Rx_Enable(USART_data.usart);
USART_Tx_Enable(USART_data.usart);
// Enable PMIC interrupt level low
PMIC.CTRL |= PMIC_LOLVLEX_bm;
// Enable global interrupts
sei();
************************************************************************
***********
bei dem RS485 steh ich voll auf dem Schlauch... habe auch keine
spezielle übung von Atmel gefunden die ich als Grundlage nehmen kann...
bei RS485 empfangen muss ich ja als erstes per interrupt erkennen ob
eine 9 bit adresse gesendet wird, dann vergleichen ob die adresse
richtig ist, in den 8 bit modus schalten, dann den Header, Daten und
CRC16 übertragen.
Zudem muss auch noch das CRC berechnet werden und soweit ich weiss auch
noch eine art Refresh auf den Bus gelegt werden. Desweiteren eine
Routine falls bei der Übertragung etwas schief geht usw...
Das alles zu programmieren ist mir zu aufwendig und ich bin sicher nicht
der Erste der vor dem Problem steht... Deshalb dachte ich mir, dass ich
da auf was bestehendes zurückgreifen könnte.