SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By dreamsky04
#35703
I just began to study program in asm,and try to code like that, right or not? have some example code for me?

LIST P=12F675, R=DEC
INCLUDE "p12f675.inc"

#DEFINE AA GPIO,0
#DEFINE SCK GPIO,1
#DEFINE CSN GPIO,2
#DEFINE MOSI GPIO,3
#DEFINE IRQ GPIO,5

ORG 000H
NOP
CLRF GPIO
BSF STATUS,PR0 ;choose bank1
movlw b'11000001' ;GP0-input, GP1-Output, GP2-outut,GP3- outut,GP4-outut, GP5-output
MOVLW TRISIO
movlw b¡¯11001000¡¯ ;Pull Ups Disabled, Rising Edge, Assigned to WDT , Prescaler is 1:1 WDT
movwf OPTION_REG
clrf ANSEL
BCF STATUS,PR0

CLRF STATUS
CLRF INTCON
CLRF GPIO

MOVLW 07H
MOVWF CMCON

CHECK
BTFSC GPIO,0
GOTO CHECK
CALL DELAY

call GetData ; read data
call SendData ; send data

goto main

---
GetData

return

---
SendData

return
By brennen
#35710
While it's definitely a good thing to be familiar with assembly language, I wouldn't recommend starting there. I use Microchip's C18 C compiler as there is a free student version (the only limitation is that you can't use some optimization after 60 days). The only catch is you have to use a PIC18 chip (it won't compile code for the PIC12 chips). Do you have any prior programming experience in higher level languages?

On my website (see in my tag line below), I have quite a few tutorials on getting the 24L01 working with the PIC18F452 using C18. All the code is on the site, as well as a write-up to explain background material. Don't forget you're also going to need a hardware programmer for any PIC you choose as they don't ship with any type of bootloader installed.