My minicomputer based on bluepill

What are you developing?
Post Reply
ebetti
Posts: 3
Joined: Tue May 11, 2021 9:24 am

My minicomputer based on bluepill

Post by ebetti »

I have built a tinycomputer based on bluepill with arduino ide.
The main board has connection for video, audio, memory card, serial ram, commodore joystick and paddles.
My first purpose is to obtain an 80x25 textual video terminal and then to add tinybasic.
Actually, with C code, i have a screen with a max width of 44x25. To obtain 80x25 i wanted to replacte the following "slow" lines:

Code: Select all

        if (scl &  1<<7) { videoDown; } else videoUp; 
        if (scl &  1<<6) { videoDown; } else videoUp; 
        if (scl &  1<<5) { videoDown; } else videoUp; 
        if (scl &  1<<4) { videoDown; } else videoUp; 
        if (scl &  1<<3) { videoDown; } else videoUp; 
        if (scl &  1<<2) { videoDown; } else videoUp; 
        if (scl &  1<<1) { videoDown; } else videoUp; 
        if (scl &  1<<0) { videoDown; } else videoUp; 
        videoUp; 
with a bit of assembler code.

I am not an expert of assembler.. the linker is blocking me and the project doesn't compile.
Attached there is the full code. Someone can help me to understand the problem ?

If someone wants to follow me in this project: i get 4 extra motherboards.. it is not possible to do a single pcb.. If you ask i will send you one for free. Just use it and let me know your results.

Code: Select all

 __asm__ volatile
        ( "ldr r2,=0x40020010\n"
          "ldr r3,=0x40020014\n"
          "ldr r4,=0x020\n"
          "ldr r0,=%0 \n"
          "tst r0,#0x80\n"   //con questa maledetta istruzione non compila..           
          "beq vdn1\n" 
          "str r4, [r3]\n" 
          "b v2\n"
          "vdn1:\n"
          "str r4, [r2]\n" 
          "v2:\n"  
          "tst r0, 0x40\n"
          "beq vdn2\n"
          "str r4, [r3]\n" 
          "b v3\n"
          "vdn2:\n"
          "str r4, [r2]\n" 
          "v3:\n"
          "tst r0, 0x20\n" 
          "beq vdn3\n"
          "str r4, [r3]\n" 
          "b v4\n"
          "vdn3:\n"
          "str r4, [r2]\n" 
          "v4:\n"
          "tst r0, 0x10\n" 
          "beq vdn4\n"
          "str r4, [r3]\n" 
          "b v5\n"
          "vdn4:\n"
          "str r4, [r2]\n" 
          "v5:\n"
          "tst r0, 0x08\n" 
          "beq vdn5\n"
          "str r4, [r3]\n" 
          "b v6\n"
          "vdn5:\n"
          "str r4, [r2]\n" 
          "v6:\n"
          "TST r0, 0x04\n" 
          "beq vdn6\n"
          "str r4, [r3]\n" 
          "b v7\n"
          "vdn6:\n"
          "str r4, [r2]\n" 
          "v7:\n"
          "tst r0, 0x02\n" 
          "beq vdn7\n"
          "str r4, [r3]\n" 
          "b v8\n"
          "vdn7:\n"
          "str r4, [r2]\n" 
          "v8:\n"
          "tst r0, 0x01\n" 
          "beq vdn8\n"
          "str r4, [r3]\n" 
          "b vend\n"
          "vdn8:\n"
          "str r4, [r2]\n" 
          "vend:\n"
          "str r4, [r3]\n" 
          : : "r" (scl) : "r0","r2","r3","r4"
        );
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: My minicomputer based on bluepill

Post by mlundin »

It is helpful to see the error messages.

Second what are these videoDown and videoUp , macros or funtions ?

Third in general the compiler mostly generates more efficient code than hand coded asm except in very special cases.
There is usually more to gain by cleaning up the C code.

Edit:
"ldr r0,=%0 \n"
should probably be
"ldr r0, %0 \n"
ebetti
Posts: 3
Joined: Tue May 11, 2021 9:24 am

Re: My minicomputer based on bluepill

Post by ebetti »

Thank you for the fast reply.

The full code was attached to the first post. You can find it here: https://185.94.88.6/pannello/stm32_video_asm.zip

VideoUp and Videodown are simply this:

#define videoUp GPIOA -> BSRR = (1 << 5);
#define videoDown GPIOA -> BRR = (1 << 5);

I corrected the "ldr" line and now i doesn0t get linker error again, but the new error is this:

C:\Users\Enrico\AppData\Local\Temp\cc0MIdGt.s: Assembler messages:
C:\Users\Enrico\AppData\Local\Temp\cc0MIdGt.s:394: Error: cannot represent T32_OFFSET_IMM relocation in this object file format
exit status 1
Errore durante la compilazione per la scheda Generic STM32F1 series.
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: My minicomputer based on bluepill

Post by mlundin »

Checked some more, %0 is in a register so mov should be used

"mov r0,%0 \n"

What is this code supposed to achive, generate a sequence of set/reset depending on scl variable, or simple set reset the pin ?
Are there specific timing requirements ?
ebetti
Posts: 3
Joined: Tue May 11, 2021 9:24 am

Re: My minicomputer based on bluepill

Post by ebetti »

Tha mov was the problem.. now the code compile. Not working but i will reach a solution.
It supposes to do the same thing of the C code: serialize SCL and use it to set/reset to pin 5 of GPIOA.
This generate the scancode of the char to show it on the screen.
I just need a code faster than C to obtain 80X25 screen.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: My minicomputer based on bluepill

Post by fpiSTM »

I guess you can speed up using a simple switch case (last videoUp call included), then you can factorize and avoid do some register access when the previous one is the same:

Code: Select all

switch(scl) {
  case 255:
  case 254:
    videoDown; videoUp;
    break;
  case 253:
    videoDown; videoUp; videoDown; videoUp;
    break;
...
   case 170:
      videoDown; videoUp; videoDown; videoUp; videoDown; videoUp; videoDown; videoUp; 
    break;
...
   case 1:
    videoDown; videoUp;
    break;
   case 0:
   default:
     videoUp;
     break;
}
User avatar
Bakisha
Posts: 139
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: My minicomputer based on bluepill

Post by Bakisha »

Interesting project.

What is is your screen for 80x25? LCD or composite video for PAL/NTSC video? Is video memory streamed from internal RAM or external RAM? Any keyboard for tiny basic inputs?
mlundin
Posts: 94
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 6
Location: Sweden

Re: My minicomputer based on bluepill

Post by mlundin »

SPI ??
Post Reply

Return to “Projects”