Click here to Skip to main content
15,895,777 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralAlas, and alack: my phone is being replaced. Pin
OriginalGriff16-Feb-20 1:58
mveOriginalGriff16-Feb-20 1:58 
GeneralRe: Alas, and alack: my phone is being replaced. Pin
lopatir16-Feb-20 2:19
lopatir16-Feb-20 2:19 
GeneralRe: Alas, and alack: my phone is being replaced. Pin
OriginalGriff16-Feb-20 2:36
mveOriginalGriff16-Feb-20 2:36 
GeneralRe: Alas, and alack: my phone is being replaced. Pin
lopatir16-Feb-20 3:04
lopatir16-Feb-20 3:04 
GeneralRe: Alas, and alack: my phone is being replaced. Pin
RickZeeland16-Feb-20 3:01
mveRickZeeland16-Feb-20 3:01 
GeneralRe: Alas, and alack: my phone is being replaced. Pin
phil.o16-Feb-20 4:38
professionalphil.o16-Feb-20 4:38 
GeneralRe: Alas, and alack: my phone is being replaced. Pin
Jörgen Andersson16-Feb-20 6:24
professionalJörgen Andersson16-Feb-20 6:24 
GeneralCounting bus cycles and nanoseconds PinPopular
CodeWraith16-Feb-20 0:55
CodeWraith16-Feb-20 0:55 
Single board computers can be boring. Without any I/O ports they can't do very much. The traditional way to change that was to add a UART (that's the good old RS232 serial port, more or less) and get yourself a terminal. Quite a sight. Some rigged board or a breadboard with a handful of ICs, hooked up to a one ton terminal.

I do have a CDP1854 UART for the Zwölf, but I don't want to add that to the breadboard yet. It also would need a baud rate generator. Too many more potential errors at this point, but Zwölf does not really need it anyway.

The CDP1802 has one single output pin that can be controlled by instructions. I used it to blink a LED for the first tests. In the old days it was used for many things at once. Sound, even speech synthesis, saving your programs to cassette tape and also emulating serial communication. There are also four separate input bits, so we could also receive bytes from the terminal or the tape recorder.

Now I have added a MAX232 IC to the Zwölf and hooked it up directly to the processor's output bit and one of the four input bits. Now I only need subroutines to send and receive ASCII characters and Zwölf will become interactive.

The following code is my subroutine to send a character to the terminal. It already does a fine job on the emulator. 1200 baud are not very much, but it will be sufficient as long as the Zwölf is clocked with only 1 MHz. It uses separate call and parameter stacks (that's what all the SEX is about). I could even have up to 15 stacks if I needed them. I also don't think that RISC processors need an excessive number of instructions to actually do something.

Now, show me how you do all that with a fancy Z80 by simply adding that MAX232. And of course faster and with even shorter code. Smile | :)

; =========================================================================================
; RS232 Out (software protocol)
; 
; Parameters:
; 01	Character to be sent (byte)
; 
; Return:
; ---
; =========================================================================================

RS232OutSoftware:	SEX  R2							; save register RE onto the call stack
					GHI  RE
					STXD
					GLO  RE
					STXD

					SEX  R6							; load parameter 01 into RE.1
					IRX
					LDX
					PHI  RE

					SEQ								; Q = 0
					LDI  BIT_COUNT					; load bit counter into RE.0
					PLO  RE

					REQ								; Q = 1 (start bit)
					LDI  BIT_DELAY					; delay for one bit phase
					PLO  RF
SER_Delay1:			DEC  RF
					GLO  RF
					BNZ  SER_Delay1

SER_TransLoop:		GHI  RE							; shift out highest bit from the character
					SHRC
					PHI  RE
					LSDF							
					REQ								; Q = 1 if bit = 0
					SKP
					SEQ								; Q = 0 if bit = 1
					
					LDI  BIT_DELAY					; delay for one bit phase
					PLO  RF
SER_Delay2:			DEC  RF
					GLO  RF
					BNZ  SER_Delay2

					DEC  RE							; decrement bitcount
					GLO  RE
					LBNZ SER_TransLoop				; shift out another bit if not done yet
					
					SEQ								; Q = 0 (last phase to get back in step)
					LDI  BIT_DELAY					; delay for one bit phase
					PLO  RF
SER_Delay3:			DEC  RF
					GLO  RF
					BNZ  SER_Delay3

					LDI  BIT_DELAY					; delay for one bit phase (stop bit)
					PLO  RF
SER_Delay4:			DEC  RF
					GLO  RF
					BNZ  SER_Delay4

					SEX  R2							; restore register RE from call stack
					IRX
					LDXA
					PLO  RE
					LDX
					PHI  RE
					SEP  R5
				
;------------------------------------------------------------------------------------------

I have lived with several Zen masters - all of them were cats.

His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.

GeneralRe: Counting bus cycles and nanoseconds Pin
Richard MacCutchan16-Feb-20 1:19
mveRichard MacCutchan16-Feb-20 1:19 
GeneralRe: Counting bus cycles and nanoseconds Pin
CodeWraith16-Feb-20 2:12
CodeWraith16-Feb-20 2:12 
GeneralRe: Counting bus cycles and nanoseconds Pin
bryanren17-Feb-20 3:54
bryanren17-Feb-20 3:54 
GeneralRe: Counting bus cycles and nanoseconds Pin
OriginalGriff16-Feb-20 1:20
mveOriginalGriff16-Feb-20 1:20 
GeneralRe: Counting bus cycles and nanoseconds Pin
Kornfeld Eliyahu Peter16-Feb-20 1:56
professionalKornfeld Eliyahu Peter16-Feb-20 1:56 
GeneralRe: Counting bus cycles and nanoseconds Pin
CodeWraith16-Feb-20 1:58
CodeWraith16-Feb-20 1:58 
GeneralRe: Counting bus cycles and nanoseconds Pin
OriginalGriff16-Feb-20 2:07
mveOriginalGriff16-Feb-20 2:07 
GeneralRe: Counting bus cycles and nanoseconds Pin
CodeWraith16-Feb-20 2:42
CodeWraith16-Feb-20 2:42 
GeneralRe: Counting bus cycles and nanoseconds Pin
Mike Hankey16-Feb-20 2:26
mveMike Hankey16-Feb-20 2:26 
GeneralRe: Counting bus cycles and nanoseconds Pin
Gary R. Wheeler16-Feb-20 5:19
Gary R. Wheeler16-Feb-20 5:19 
GeneralRe: Counting bus cycles and nanoseconds Pin
CodeWraith16-Feb-20 5:44
CodeWraith16-Feb-20 5:44 
GeneralRe: Counting bus cycles and nanoseconds Pin
CPallini16-Feb-20 7:35
mveCPallini16-Feb-20 7:35 
GeneralRe: Counting bus cycles and nanoseconds Pin
Gary R. Wheeler16-Feb-20 11:50
Gary R. Wheeler16-Feb-20 11:50 
GeneralRe: Counting bus cycles and nanoseconds Pin
CodeWraith16-Feb-20 13:26
CodeWraith16-Feb-20 13:26 
RantBook authors, if you don't provide example code, I don't believe you. Pin
honey the codewitch15-Feb-20 23:48
mvahoney the codewitch15-Feb-20 23:48 
GeneralRe: Book authors, if you don't provide example code, I don't believe you. Pin
Amarnath S16-Feb-20 0:54
professionalAmarnath S16-Feb-20 0:54 
GeneralRe: Book authors, if you don't provide example code, I don't believe you. Pin
honey the codewitch16-Feb-20 5:58
mvahoney the codewitch16-Feb-20 5:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.