HelloWorld CPLD/VHDL Edition

Altera MAX II EPM240 CPLD Development Board
Altera MAX II EPM240 CPLD Development Board Brassboard Learning

ALTERA FPGA CycloneII EP2C5T144 Minimum System Board
ALTERA FPGA CycloneII EP2C5T144 Minimum System Board for Learn

And the code

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity LED2 is
port (
clk : in std_logic;
led : out std_logic);
end entity;

architecture meh of LED2 is
signal count : std_logic_vector (23 downto 0);
begin
led <= count(23); process(clk) begin if rising_edge(clk) then count <= count + 1; end if; end process; end architecture;

“Hello World” ARM Edition

As usual with MCUs – first goal is to light a LED.

/*
* LED connected to PB0
* do not forget current limiting resistor(!)
*/

#include "stm32f103.h"

// RAM starts at 0x20000000
// Stack at 0x20001000 (4Kbyte stack)
__asm__(".word 0x20001000");
__asm__(".word main");

void main()
{
unsigned int c = 0;

// enable port B clock
RCC_APB2ENR = (1 << 3);

// set up pin B0 as output (push-pull)
GPIOB_CRL &= 0xfffffff0;
GPIOB_CRL |= 0x00000001;

while(1) {
GPIOB_BSRR = (1 << 0); // ON
for(c = 0; c < 100000; c++);
GPIOB_BSRR = (1 << 16); // OFF
for(c = 0; c < 400000; c++);
}
}

And here is how you build the binary

arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -c main.c
arm-none-eabi-ld -T blink.lds main.o
arm-none-eabi-objcopy -j .text a.out blink.bin -O binary
st-flash write blink.bin 0x08000000