Again other things I fear here are timing, accuracy and wonder how much each of the pulses on/off times count ..... any chance someone has done this before /or has ideas? Or foresees other things im up against?
movlw .200
addlw .100
I have been taking some time reading the asm on datasheet of the pic16f, the block diagram makes alot more sense now of what is going on under there! but also so many questions, for starts I understand that the w register is the one feeding the alu and k is when passing in a literal value,
but what are the f and b registers? i did not see them in the block diagram.
also I am aware of what the stack basically is and how to keep it from overflowing .... but how does it actually work, what values is it storing there when i go in to each layer?
also I am looking at the descriptions of the operands and even those are confusing even if they are in English, such as:
Inclusive OR W with f
Swap nibbles in f
Rotate Left f through Carry
and where do the answers go after the operation is done.....ie..what/where is the d register, or is that exactly what d is defining?
I know we have working tutorials of this stuff, but is there one kicking around that explains each of the operands in a little more detail?
What else i find is that very short delays inserted into the stream dont seem to matter even though they dont belong there. For example, if you call a subroutine to generate the start signal, then call a different routine to send the code, then another routine for the ending sequence, the time it takes for each call and return dont seem to matter to the device. I never investigated how much i could get away with though.
I believe the stack fills up when you do things like this if{while{for{if{while{for{}}}}}} <-- so that would take up 6 stacks, I often eliminate consumption by doing things such as replacing while(1) with goto:begining; and/or creating global flags and calling if's .... more over it doesn't matter that much but I was just curious as to what value is actually stored in a stack that is so important, ie is it the return value place holder , or a place to store the if or while instruction that it is in?
genius Nigel! I forgot that these would use a standard "protocol", so i searched it! LG uses the NEC protocol!
(things like the protocol says 540us, but actually I was delaying 600us .. its difficult for scope to get zoomed in that close and use the one-shot ... mostly cause of the long start bit)
I believe the stack fills up when you do things like this if{while{for{if{while{for{}}}}}} <-- so that would take up 6 stacks, I often eliminate consumption by doing things such as replacing while(1) with goto:begining; and/or creating global flags and calling if's .... more over it doesn't matter that much but I was just curious as to what value is actually stored in a stack that is so important, ie is it the return value place holder , or a place to store the if or while instruction that it is in?
No worry's, i won't be building a bread board computer any time soon, mine would never be as tidy as that either! but it was a great lesson in how all the registers tie in together. What i find most fascinating is how instructions are decoded to simply being which set and enable pins are active and how the data passes in the microsteps (it also solves the mystery of why all these IC's that i buy have set and enable pins!)
genius Nigel! I forgot that these would use a standard "protocol", so i searched it! LG uses the NEC protocol! Which adds another mystery of why i only received 28 bits!
I will do up a sub to follow the protocol better and see if transmitting is then more successful. I think my worry was mostly about pulse time accuracy. (things like the protocol says 540us, but actually I was delaying 600us .. its difficult for scope to get zoomed in that close and use the one-shot ... mostly cause of the long start bit)
https://www.sbprojects.com/knowledge/ir/nec.php
;**********************************************************************
; *
; Filename: serial.asm *
; Date: *
; File Version: *
; *
; Author: Burt E Ratliff *
; Company: *
; *
; *
;**********************************************************************
; *
; Files Required: P12F508.INC *
; *
;**********************************************************************
; *
; Notes: *
; *
;**********************************************************************
list p=12F508 ; list directive to define processor
#include <p12F508.inc> ; processor specific variable definitions
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC
; pin assignments
#define TX GPIO,0 ; transmit pin on GP0
;***** VARIABLE DEFINITIONS
UDATA
buffer res 1
counter res 1
Count res 1
;**********************************************************************
; Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw k, where the k is a literal value.
RESET CODE 0x000 ; effective reset vector
movwf OSCCAL ; update OSCCAL with factory cal value
goto init ; jump to main program
init
movlw b'00000000' ; set I/O
tris GPIO
bsf TX
movlw 'b' ; sets text to loads buffer with
call start
movlw 'e'
call start
movlw '8'
call start
movlw '0'
call start
movlw 'b'
call start
movlw 'e'
call start
movlw ' '
call start
movlw 'w'
call start
movlw 'a'
call start
movlw 's'
call start
movlw ' '
call start
movlw 'h'
call start
movlw 'e'
call start
movlw 'r'
call start
movlw 'e'
call start
movlw 0x0A
call start
movlw 0x0D
call start
goto init ;loop for ever
start
movwf buffer
movlw 0x08
movwf counter ; counts the 8 bits
bcf TX ; set TX low
call BItdelay ; delay to get a 9600 bit rate
TXLoop
rrf buffer ,f ;send one bit
btfss STATUS ,C ;
bcf TX ;
btfsc STATUS ,C ;
bsf TX ;
call BItdelay ;
decfsz counter,f ;test if all done
goto TXLoop ;
bsf TX ;
call BItdelay ;
return
BItdelay ; timing delay
movlw 0x17
movwf Count
Wait
nop
decfsz Count ,f
goto Wait
return
END ; directive 'end of program'
Normally the stack on medium pics is 255 bytes....
PORTC |= 0b00100000;
__delay_us(5);
PORTC &= 0b11011111;
__delay_us(2);
asm("NOP");
asm("NOP");
counter--;
void IRon(int delayTime)
{
while (counter > 0){
#asm
BItdelay ; timing delay<----repeat definition error here
movlw 0x17
movwf Count
#endasm
}}
#include<xc.h>
#define _XTAL_FREQ 4000000 // or whatever!
void main(void)
}
__delay_us(20);
{
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?