PIC Assembler Observation

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
This tutorial covers about 35 to 45 areas of Baseline assembler.

If somebody does the Midrange assembler lessons also.

You end up with sort of a 'PIC Toolbox'..

A concise knowledge of what can be done with a PIC.

If you want to 'fly by the seat of your pants'.

Armed with this knowledge you can just pick out your 'tools' and go at a project.

Just 'get it done'.

Anybody else look at PIC's this way?
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you

Okay.

That's the way I'm starting to look at it then.

You can pick up the Datasheet or these tutorials.

Then for example find 'Serial Communication'.

'I'm going to add serial communication to my project.

Not everything being covered in tutorial is something you are going to use every program you write
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Joey

IF you have information about how to use a PIC.

A datasheet for 10F200 let's say.

You can look at it as a 'toolbox'.

If you want to do something you look up the section in datasheet.

That section would be a 'tool.

Do you agree? Yes/No?
 

joeyd999

Joined Jun 6, 2011
5,283
Thank you Joey

IF you have information about how to use a PIC.

A datasheet for 10F200 let's say.

You can look at it as a 'toolbox'.

If you want to do something you look up the section in datasheet.

That section would be a 'tool.

Do you agree? Yes/No?
No. A datasheet is documentation. A hammer -- or an assembler -- is a tool.
 

be80be

Joined Jul 5, 2008
2,072
You no if you really want do serial then forget 10f200 and 12f509 or 508 and use a chip like 16f1825 Or a 12f1822
The first 3 don't have serial has to bit bang it which I posted code that works on all 3 with little simple changes
The last 2 you can use MMC in mplab and be doing serial in no time flat. I2C spi ADC timers you name it but you got read the files.
Nice samples like this
Code:
void main(void) {
                                // initialize the device
                                SYSTEM_Initialize();
                                uint8_t data;
                              
                                // Enable the Global Interrupts
                                INTERRUPT_GlobalInterruptEnable();
                              
                                // Enable the Peripheral Interrupts
                                INTERRUPT_PeripheralInterruptEnable();
                              
                                printf("\t\tTEST CODE\n\r");        //Enable redirect STDIO to USART before using printf statements
                                printf("\t\t---- ----\n\r");
                                printf("\t\tECHO TEST\n\r");
                                printf("\t\t---- ----\n\n\r");
                                printf("Enter any string: ");
                                do{
                                data = EUSART_Read();        // Read data received
                                EUSART_Write(data);            // Echo back the data received
                                }while(!EUSART_DataReady);        //check if any data is received
                              
                            }
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Bebe

Okay.

Made a another 'Forum mistake'.

That was just an example.

I am just saying tutorial covers 'Everything'.

When you write some programs you are not going to use 'Everything'.

Just beginning to notice that doing Tutorial.
 
Last edited:

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you Bebe

Been taking a break from the tutorial.

Lesson 7 is up next.

Yep. He may not cover some of the 'combined' type subjects.

Where it's a whole lot of pieces put together.

We'll see.
 

TQFP44

Joined Sep 3, 2016
51
Its good to start with PIC's and assembler, "walk before you run " theory worked for me . I would take .asm examples and modify them , tried many PIC16F devices. The main tool you need to understand is MPLAB SIM ... single step and watch the registers, check the program flow, a tutorial is just the authors way of doing things there are many ways to skin a rabbit :) Hardware .... a simple bread board / strip board + programmer set up will do. Main thing have fun.
 

Thread Starter

PICNewbee

Joined Mar 31, 2017
355
Thank you TQFP 44

'Its good to start with PIC's and assembler'

We are in a minority. Wish I had $20 for how many times I've heard

'Get a 18F blank. Get a 32MX blank.Start out with a cutting edge PIC'
 

be80be

Joined Jul 5, 2008
2,072
Tqfp44 that's very true there is 100 of ways to do the same thing but just writing code and see what it does is the best and the sim is a great tool to see what happens.
Hopping around don't really work well get lost that way.

What get's me about tutorials is there not like you said the only way some not even close because there not clearly laid out.
Like the arduino you can read a 100 to do the samething and haft have left out the main parts.
The data sheet from the pic read it try getting the pic to work was the best way for me and seeing it happen with the sim.
I wanted serial with the 12f508 I found some code in C for a 8080
second 8-bit microprocessor designed and manufactured by Intel and was released in April 1974
I spent a week with the datasheet and the code works great I posted it 8 years ago and and got maybe 5 people showing the take of bit bang serial and there's worked too. It's got be fun I like my fun just doing it.
serial bit bang for chip without serial.
Code:
code
;**********************************************************************
;                                                                     *
;    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'
 
Top