Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Pic12F683 LCD question

Status
Not open for further replies.
It sounds like you didn't put it in a loop. It executes it once, but then stops. Did you write the program in ASM, or did you use the C file? It may also be the watchdog timer--I've had a few issues with that before, too :D

the only thing i could think of giving me the brief blink was that the programm executed that fast .

I could try to add a longer delay to see if it is blinking single led's .

or maybe alter this part of the code so it starts all over again.

Code:
Loop				;  Loop Forever when Done

  goto   Loop
 
Well, as I think I suggested, if you're using MPLAB and the PK2, you can use the PICkit in-circuit debugger to find out where it's going wrong. This helps a lot, because you can step through the code and see what each instruction does in the actual circuit. It is extremely useful, and I suggest you give it a try.

Keep us posted!
Der Strom
 
Well, as I think I suggested, if you're using MPLAB and the PK2, you can use the PICkit in-circuit debugger to find out where it's going wrong. This helps a lot, because you can step through the code and see what each instruction does in the actual circuit. It is extremely useful, and I suggest you give it a try.

Keep us posted!
Der Strom

i'm currently using a JDM programmer but as soon as i get the hang of pic programming i will spend some money on a pickit 2 .. i have heard that they are better thant pickit 3 but how are the pickit 2 clones compared to the orignal ??
 
i'm currently using a JDM programmer but as soon as i get the hang of pic programming i will spend some money on a pickit 2 .. i have heard that they are better thant pickit 3 but how are the pickit 2 clones compared to the orignal ??

I've heard many recommendations for each of those. There was just another thread on the forum that I was posting in, and learned that the PICkit2 is becoming obsolete, and that microchip is urging customers to buy the PK3 instead. However, the PK2 still works great for the many of the standard "classic" chips, which is why I have one myself. I have never had a problem with it, and it works great.

As for the clones, I would just buy the original. It doesn't cost more than $35 USD and is easy to find. If you have the money, definitely buy the original.
 
I've heard many recommendations for each of those. There was just another thread on the forum that I was posting in, and learned that the PICkit2 is becoming obsolete, and that microchip is urging customers to buy the PK3 instead. However, the PK2 still works great for the many of the standard "classic" chips, which is why I have one myself. I have never had a problem with it, and it works great.

As for the clones, I would just buy the original. It doesn't cost more than $35 USD and is easy to find. If you have the money, definitely buy the original.

I guess i wil go for the orginal pickit 2 not sure about the pickit 3... here is a reviwe eevblog PICKIT 3 reviwe
 
ok so i have spendt the weeken reading and trying some ideas but without any luck :( .. I do manage to send a bit at the time but i need to be able to send things like b'00011100' or 0x20 or whatever to the shift register .. the setup is the same as this one https://embedded-lab.com/blog/?p=30 ..
 
i made this code just to see if i could send a sequens of data to the shift register but it didn't work the way i hoped it would ..

Code:
;********************************************************************
;
; Programmert av 	: Stig Larsen
;
; Pic mcu 			: 12F683
;
; Versjon			:
;
; Rev					:
;
; Dato				:
;
;********************************************************************
;
;*******************pic init*****************************************

 list	p=12f683		; list directive to define processor
#include <p12F683.inc>
     __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF)
;
;*************** cblock Variabler ************************************
		cblock 0x20
Temp		;Temp variabel	
	d1
	d2
	d3
	
	endc
;*********************Register oppsett********************************
		org 0 ;Flash start adresse 0
Start:
		bsf 	STATUS,RP0 ;Bank 1
		movlw 0x47
		movwf OSCCON ;4 MHZ oscilator  (0x70 = 8 MHZ)
		clrf 	TRISIO ; ALLE I/O porter =output 
		clrf	ANSEL	 ; Alle I/O porter =digital
		bcf	STATUS,RP0 ;Bank 0
;********************HOVED PROGRAMM ************************************

Main:
		movlw 0x02
		movwf Temp

		
		movf GPIO,1
		call Clock
		;call Delay
		incf	Temp,1
		goto	$-4
		
Clock:
		bsf 	GPIO,2
		nop
		nop
		bcf	GPIO,2		
		return
Delay
			;999990 cycles
	movlw	0x07
	movwf	d1
	movlw	0x2F
	movwf	d2
	movlw	0x03
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0

			;6 cycles
	goto	$+1
	goto	$+1
	goto	$+1

			;4 cycles (including call)
	return
		
		end
any ideas on how i can send the data to the register ?
 
Hi Lurkepus,
Below is a snippet for shifting one byte out to a shift register, sendreg is the data to be sent out and where I have done gpio(n) this will be the port pins numbers you assign.

Code:
ser-out    movwf    sendreg           ;save copy of number
              movlw    0x08                ; load count for 8 bits
              movwf    count

testbit      bcf        gpio(n)             ; clear bit (default)
              btfsc    sendreg,7           ; test upper bit
              bsf      gpio(n)                ; set bit

clock       bcf    gpio(n)
              nop                              ; send clock pulse
              bsf    gpio(n)

roflt        rlf        sendreg,f              ; shift left
             decfsz  count,f                 ; decrement bit
 goto      testbit                             ; next bit
             bcf    gpio(n)
             nop                                 ; extra clock pulse if
              bsf    gpio(n)                 ; clocks are tied

    return                              ;done
So for the LCD you would load in either the command or data byte then use another gpio(n) pin to clock the Enable pin for the lcd.

Hope this helps

Regards Bryan
 
Last edited:
Hi Bryan


Thanks alot for the code .. i will try it and see if i can get it to work :) .. to me it look like the only thing i need to do is to add count and sendreg to the cblock ,add the data i want to send to sendreg and call the routine you have posted :) .. just need my morning coffee and i will start to write the code :)

Stig AkA Lurkepus
 
Last edited:
i have writen some testcode but i got a few errors during compiling

Code:
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 44 : Symbol not previously defined (ser)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 44 : Symbol not previously defined (out)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 47 : Symbol not previously defined (ser)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 47 : Symbol not previously defined (out)
Error[108]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 53 : Illegal character (-)
Error[108]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 58 : Illegal character (:)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 59 : Symbol not previously defined (gpio)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 61 : Symbol not previously defined (gpio)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 64 : Symbol not previously defined (gpio)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 66 : Symbol not previously defined (gpio)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 70 : Symbol not previously defined (testbit)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 71 : Symbol not previously defined (gpio)
Error[113]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 73 : Symbol not previously defined (gpio)
Halting build on first failure as requested.
 
Last edited:
This is the code i wrote

her is the code i wrote
Code:
Temp		;Temp variabel	
	d1
	d2
	d3
	sendreg
	count
	endc
;*********************Register oppsett********************************
		org 0 ;Flash start adresse 0
Start:
		bsf 	STATUS,RP0 ;Bank 1
		movlw 0x47
		movwf OSCCON ;4 MHZ oscilator  (0x70 = 8 MHZ)
		clrf 	TRISIO ; ALLE I/O porter =output 
		clrf	ANSEL	 ; Alle I/O porter =digital
		bcf	STATUS,RP0 ;Bank 0
;********************HOVED PROGRAMM ************************************

Main:
	movlw 0x20
	movwf sendreg
	call ser-out
	movlw 0x45
	movwf sendreg
	call ser-out
loop:
  goto loop	
		
		
		
ser-out:    		
					movwf    sendreg           ;save copy of number
             	movlw    0x08                ; load count for 8 bits
               movwf    count
 
testbit :       
					bcf   gpio,1             ; clear bit (default)
               btfsc  sendreg,7           ; test upper bit
               bsf      gpio,1                ; set bit
 
clock:         
					bcf    gpio,2
              nop                              ; send clock pulse
              bsf    gpio,2
 
roflt        rlf        sendreg,f              ; shift left
             decfsz  count,f                 ; decrement bit
 goto      testbit                             ; next bit
             bcf    gpio,2
             nop                                 ; extra clock pulse if
              bsf    gpio,2                 ; clocks are tied
 
    return                              ;done
 
Last edited:
i' working on putting the LCD on a breadboard and i'm about ready to test it but i have a question how do i put a textstring on the LCD like hello world ? do i need to convert it in to hex first ??
 
Thanks I't worked .. atleast in Mplab Sim :) btw are there a way to send whole words instead of single letters ?

I believe you can send character strings, yes. At least in most compilers you can....
 
I believe you can send character strings, yes. At least in most compilers you can....

I did try to send a string but got this error message
Code:
Error[124]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 48 : Illegal argument (expected single character)
 
I did try to send a string but got this error message
Code:
Error[124]   C:\PROGRAMFILER\MICROCHIP\PROSJEKT\A1TEST.ASM 48 : Illegal argument (expected single character)

You would have to define it as a string, not a single character.
I use C, though, not ASM. In C, it is much easier to send entire strings. However, I believe there's a command in ASM that looks something like this:

Code:
 dt      "Hello world! \0"

I can't be sure of this, though.
Der Strom

EDIT: 'dt' means "data table". You can read up on them at this page: **broken link removed**
 
Last edited:
You would have to define it as a string, not a single character.
I use C, though, not ASM. In C, it is much easier to send entire strings. However, I believe there's a command in ASM that looks something like this:

Code:
 dt      "Hello world! \0"

I can't be sure of this, though.
Der Strom

i will give it a try but i'm not sure how to get the data table into the w register.. as i said i'm new to this :)
 
i will give it a try but i'm not sure how to get the data table into the w register.. as i said i'm new to this :)

No worries--I'm learning right now too :D I started learning ASM quite a while back, but I quickly turned to C. The tutorials at **broken link removed** helped me a lot, and they may help you too. I posted a link to the tutorial with data tables in my edit of post #38
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top