Uart Access

The pyCPU comes with an embedded RS232 Hardware-Unit:

The unit does a 8 bit transmission with no parity and one Stopbit. The usage of the now tightly  integrated UART unit  is demonstrated in the code below. This file sends 0,1,2,3,4,5,6,7,8,9,….. with the RS232-Unit. Everything that is received from the RS232-Unit shown at the IO-Port: PORTD_OUT.

  "Prog_mem_SIZE":1024,          # Spezifies the minimal programm length, the programm memory will have this lenght even if the current programm dont needs it  
  "Var_mem_SIZE":128,            # Size of the Memory for local variables 
  "Globals_mem_SIZE":128,        # Size of Global memory + constants memory + PREDEFINED_IO_ADDRESSES
  "STACK_SIZE":4,                # Minimal Size of one local Stackblock, that the cpu implements, even if the programm needs less stack
  "CPU_BITWIDTH":8,              # Bitwidth of integer values
  "CPU_CLK_FREQ":12e6,           # Needed to for RS232 Baudrate calc
  "CPU_RS232_BAUDRATE":115200,   # Baudrate of the RS232 Unit 
  "NR_FUNCTION_ARGUMENTS":8,     # Limits the maximal number of arguments in a function call
  "NR_NESTED_LOOPS":32           # Limits the maximal number of nested Loops
def main():
  while 1:
    ##### RS232 Transmitting ######
    # Only write something to the Transmit buffer if not full
    if not RS232_WRITEBUFFER_FULL:
      # Write the value of x to the RS232 Transmit 
      # buffer, sending the Data is then started automatically

    ##### RS232 Receiving ######
    # Wait until a byte is received in the Receive-Buffer
      # Read data from RS232 receive buffer at the RS232_READ_ADDRESS
      # Set the Read address the address where the next data will be received


  • Easier access to RS232 than in most Microcontrollers today
  • Receive-/ and Transmit-Buffer (Buffersize is set in the hardware description)


  • No interrupt
  • No dynamic baudrate configuration
  • Only 8 Bit Mode, no parity bit and 1 Stopbit
  • If you want more options you have to upgrade the hardware description

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: