#81436 - a4_jet - Sat Apr 29, 2006 4:19 am
Hi,
I'm fairly new to GB programming and have started my first program, which is a program to recieve serial information from a car's ECU and then display it to the driver.
Im trying to setup the UART on the GBA to recieve 8 bit RS232 data set at 9600 bps.
I had a look at this post to intialize the UART
http://forum.gbadev.org/viewtopic.php?t=1307&highlight=uart
I have used most of this code but i'm trying to debug it now using visual ham.
This is it so far
I am having trouble understanding this part of the code and it is the part im having difficulty debugging
I understand that it is setting up the UART port, but i'm not understanding the code. What does a | do in regards to the code?
Is it simplier way to enable all the registers for UART control at once? instead of writing individual code for each register you want to enable.
Im totally stuck i've been trying to read up on c programming but cant find anything about this "|".
Thanks
a4_jet
OOPS i should have put this in the C code help section, sorry...
I'm fairly new to GB programming and have started my first program, which is a program to recieve serial information from a car's ECU and then display it to the driver.
Im trying to setup the UART on the GBA to recieve 8 bit RS232 data set at 9600 bps.
I had a look at this post to intialize the UART
http://forum.gbadev.org/viewtopic.php?t=1307&highlight=uart
I have used most of this code but i'm trying to debug it now using visual ham.
This is it so far
Code: |
//UART intilization // Register base address #define REG_BASE 0x4000000 // Serial IO Registers #define REG_SIOCNT *(volatile unsigned short int *)(REG_BASE + 0x128) // Serial control #define REG_SIODATA8 *(volatile unsigned short int *)(REG_BASE + 0x12a) // Serial data #define REG_RCNT *(volatile unsigned short int *)(REG_BASE + 0x134) // General IO // UART settings #define SIO_USE_UART 0x3000 \\must be set for 1 for uart mode // Baud Rate #define SIO_BAUD_9600 0x0000 \\sets the input to 9600 #define SIO_BAUD_38400 0x0001 #define SIO_BAUD_57600 0x0002 #define SIO_BAUD_115200 0x0003 #define SIO_CTS 0x0004 #define SIO_PARITY_ODD 0x0008 #define SIO_SEND_DATA 0x0010 #define SIO_RECV_DATA 0x0020 #define SIO_ERROR 0x0040 #define SIO_LENGTH_8 0x0080 \\recieves 8 bit data #define SIO_USE_FIFO 0x0100 #define SIO_USE_PARITY 0x0200 #define SIO_SEND_ENABLE 0x0400 \\sets the uart to send #define SIO_RECV_ENABLE 0x0800 \\sets the uart to recieve #define SIO_REQUEST_IRQ 0x4000 \\sets an interrupt when send, recieve and error flag are set. //----------------------------------------------------------------------------------- // Init UART REG_RCNT = 0; //turns the uart on in the gba REG_SIOCNT = 0; //intializes all the uart control values to zero. REG_SIOCNT = SIO_BAUD_9600 | SIO_LENGTH_8 | SIO_RECV_ENABLE | SIO_USE_UART | SIO_REQUEST_IRQ ; REG_SIOCNT |= SIO_RECV_DATA | SIO_SEND_DATA; //----------------------------------------------------------------------------------- |
I am having trouble understanding this part of the code and it is the part im having difficulty debugging
Code: |
REG_SIOCNT = SIO_BAUD_9600 | SIO_LENGTH_8 | SIO_RECV_ENABLE | SIO_USE_UART | SIO_REQUEST_IRQ ; REG_SIOCNT |= SIO_RECV_DATA | SIO_SEND_DATA; |
I understand that it is setting up the UART port, but i'm not understanding the code. What does a | do in regards to the code?
Is it simplier way to enable all the registers for UART control at once? instead of writing individual code for each register you want to enable.
Im totally stuck i've been trying to read up on c programming but cant find anything about this "|".
Thanks
a4_jet
OOPS i should have put this in the C code help section, sorry...