AnsweredAssumed Answered

UART ADUCM350 without library

Question asked by capitano88 on May 11, 2017
Latest reply on May 24, 2017 by capitano88

Hi guys,

 

I am trying to program the UART without library.

So I want to send a message and I wrote this code:

 

#include <stdlib.h>
#include <stdio.h>

 

//UART Register
#define COMCTL *((long*)0x40005030) // UART Control Register
#define COMDIV *((long*)0x40005028) // Baud Rate Divider Register 
#define COMFBR *((long*)0x40005024) // Fractional Baud Rate Register 
#define COMLCR *((long*)0x4000500C) // Line Control Register
#define COMTX *((long*)0x40005000) // Transmit Holding Register
#define COMRX *((long*)0x40005000) // Receive Buffer Register
#define COMLSR *((long*)0x40005014) // Line Status Register
#define COMIEN *((long*)0x40005004) // Interrupt Enable Register


//GPIO Register
#define GP0CON *((long*)0x40020000) // GPIO Port 0 Configuration
#define GP0OEN *((long*)0x40020004) // GPIO Port 0 Output Enable
#define GP0IEN *((long*)0x4002000C) // GPIO Port 0 Input Enable

 

main()
{
COMCTL = 0x0; //'UART enable


GP0CON = 0xA000; / PIN 0.7 and PIN 0.6 as Rx e Tx
GP0OEN |= 0x40; // pin 0.6 (Tx) as Output
GP0IEN |= 0x80; //pin 0.7 (Rx) as Input


COMIEN = 0x3A; // interrupts disable

//Baud Rate = 9600
COMDIV = 0x11; //COMDIV =17
COMFBR = 0x9883; // FBEN=1, M=3 e N=131

 

//start communication
COMTX = 0x1;
while(!(COMLSR && 0x60)); //wait till COMTX and Transmit Shift Register are empty in order to avoid overwrite
COMTX = 0x1;
while(!(COMLSR && 0x60));
COMTX = 0x1;
while(!(COMLSR && 0x60));
COMTX = 0x1;
while(!(COMLSR && 0x60));
COMTX = 0x1;
while(!(COMLSR && 0x60));
}

 

I am using Termite 3.2 as communication tool (I tried also UART_Terminal_NET_4.5) but the riceved word is always the same showed in the attached screenshot. 

 

What is wrong?

 

PS: obviously I tried to change the value of the sending bits and I checked the right configuration of 5 bit word, 1 stop bit, none parity check and Baud Rate for Termite. 

Attachments

Outcomes