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.

Question with PIC16C745

Status
Not open for further replies.

ash87

New Member
Hi im currently working on PIC16C745 using MPLAB in assembly language..I have this GSm modem, when the OUTPUT is "ON" it be connected to GND and once it is connected to GND, it wil light up the LED RB0. ( the RTC i have not it work out yet) So after an hr ltr, the PIC will send a Signal to the GSM input, then the GSM will detect the Signal thus the modem will send a SMS to the User.So on and so for... But the problem is the LED does not light up..And i cant figure out why..PLEASE HELP!

I have this message shown on the output window after i build the source code:
Message[302] C:\DOCUMENTS AND SETTINGS\PROJECT\MY DOCUMENTS\ASHLEY055162R\TRAIL\ASH\P16C745\GSM\GSM.ASM 12 : Register in operand not in bank 0. Ensure that bank bits are correct.
( AND it is pointed to TRISA and TRISB)

This is my Soure code:
Code:
#include <p16c745.inc>  ; include the defaults for the chip 

  org 0x00000020 
Start 
clrf STATUS 
clrf PORTB            ; clear PORTB output latch 
clrf  PORTA           ; Clear PORTA output latch 
movlw b'00000000' ; Set all pins PORTB as output 
movwf TRISB 
ON 
btfsc PORTA,4       ; Is GSM output ON? 
goto ON               ; No, go back check again 
bsf  PORTB,0        ; turn on RB0 (LED) only! 

; RTC will start counting 1hr 
;----------------After RTC finish counting 1hr------------ 
Start1 
clrf PORTA            ; clear PORTA output latch 
movlw b'00010000' ; Set RA4 as Input port,and the rest as output 
movwf TRISA  
bsf  PORTA,3         ; Set RA3 and Send signal '1' to modem input 

;-----------------Application turn off-------------------- 
DebounceA 
btfss PORTA,4       ; Is Modem output OFF? 
goto DebounceA    ; No, wait somemore 
OFF 
bcf  PORTB,0        ; Turn off RB0 (LED) only 

Start2 
bcf  PORTA,3        ; Clr RA3 and Send signal "0" to Modem input 
goto Start 
end
 
You have to jump to bank 1 to access to TRIS registers

use this code before moving a value to TRIS registers this shows make all PORTB outputs

Code:
	bsf	STATUS,RP0	;goto bank1
	clrf	TRISB
	bcf	STATUS,RP0	;goto bank0

To make RA4 input use like this

Code:
	bsf	STATUS,RP0	;goto bank1
	movlw	b'00010000'
	movwf	TRISB
	bcf	STATUS,RP0	;goto bank0
 
Last edited:
It also seems a REALLY bad choice of device, why use an OTP PIC?, there are plenty of EEPROM or FLASH devices, even with USB if that's a consideration? - which is the only reason to select a 16C745 anyway!
 
Last edited:
Gayan Soyza said:
To make RA4 input use like this

Code:
	bsf	STATUS,RP0	;goto bank1
	movlw	b'00010000'
	movwf	TRISB
	bcf	STATUS,RP0	;goto bank0

Using TRISB to control RA4. :eek:
 
PORTA pins are multiplexed with analog inputs. Make sure you configure the ADCON1 register properly.
As suggested, look for a FLASH device, that allows to debug your code easily.
 
im tasked by my teacher to use that..im doing my final Year project.. so i cannot choose. By the way, i have tried using that, but stil i got the same error message..or do i need to define anythin??

Code:
#include <p16c745.inc>  ; include the defaults for the chip 

  org 0x00000020 

Start 
   bsf        status, RP0     ; select bank 1
   clrf        PORTB            ; clear PORTB output latch 
   clrf        PORTA            ; Clear PORTA output latch 
   movlw    b'00000000'     ; Set all pins PORTB as output 
   movwf   TRISB 
   bcf	  STATUS,	RP0     ; go to bank 0

ON 
   btfsc    PORTA,4        ; Is GSM output ON? 
   goto    ON                ; No, go back check again 
   bsf      PORTB,0         ; turn on RB0 (LED) only! 

; RTC will start counting 1hr 
;----------------After RTC finish counting 1hr------------ 
Start1 
   bsf	   STATUS,RP0       ;select bank 1
   clrf         PORTA            ; clear PORTA output latch 
   movlw     b'00010000'     ; Set RA4 as Input port,and the rest as output 
   movwf    TRISA  
   bcf        STATUS, RP0      ; go to bank 0
   bsf         PORTA,3         ; Set RA3 and Send signal '1' to modem input 

;-----------------Application turn off-------------------- 
DebounceA 
   btfss     PORTA,4       ; Is Modem output OFF? 
   goto      DebounceA    ; No, wait somemore
 
OFF 
   bcf       PORTB,0        ; Turn off RB0 (LED) only 

Start2 
   bcf      PORTA,3        ; Clr RA3 and Send signal "0" to Modem input 
   goto    Start 
end
 
Last edited:
Your start1 must be like this

Code:
Start1 	bsf	STATUS,	RP0 ;select bank 1
   	clrf    TRISB       ; clear TRISB output latch 
   	clrf     TRISA 
   	bcf	STATUS,	RP0 ;select bank0

If you set RA4 as an input pin in the beginning you don't need to make RA4 as input every time before checking the RA4 button.

In sudden changes if you want to make RA4 from output to input use this

Code:
Start1 	bsf	STATUS,	RP0 ;select bank 1   	
   	movlw   b'00010000' ; Set RA4 as Input port,and the rest as output 
   	movwf   TRISA  
   	bcf	STATUS,	RP0 ;select bank0
 
Last edited:
errorlevel -302 ; supress "register not in bank0, check page bits" message
-------------------------------------------------------
hey guys i juz find out the answer, This is the sentence u need to add above.. anyway thanks for the help.. I really appreciate it.. = )
 
Last edited:
ash87 said:
what do u meant by that??
Code:
Start 
   clrf     PORTB           ; clear PORTB output latch 
   clrf     PORTA           ; Clear PORTA output latch 

   bsf      status, RP0     ; select bank 1

   MOVLW    0x06            ; Configure all pins
   MOVWF    ADCON1          ; as digital inputs

   ....
Check section 5 in the datasheet.
 
ash87 said:
im tasked by my teacher to use that..im doing my final Year project.. so i cannot choose.

Doesn't he like you? :p

It's about up there with making you wear boxing gloves while soldering!, using an OTP chip drastically slows down development, and costs an incredible amount more to do. To get any development speed at all you need multiple JW series eraseable chips, and multiple erasers for them - so you have a fresh chip to write to every time you want one. With an EEPROM or FLASH PIC you simply overwrite the chip in seconds, and can even do it in-circuit if required.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top