PDA

View Full Version : 18f4550-problem output



MINHLE
- 27th May 2013, 03:46
hi,

the output of 18f4550 is double i.e.suppose 1 led is on, but 2 leds are on instead.
can anyone help?

Demon
- 27th May 2013, 14:17
Showing your code will help others to help you.

Robert

MINHLE
- 27th May 2013, 18:04
the code runs well with pic16f (slightly modify it)

problem with 18f4550 (particlar 74hc595) ?, all internal osc are disable and switch osc : off) osc set to XTPLL.
problem appears in the program.

INCLUDE "modedefs.bas"
include "ALLDIGITAL.pbp"
'ADCON1=7
TRISB=0
portb = 0

PAUSE 20
DEFINE OSC 8

II VAR BYTE
X VAR byte
W VAR BYTE
MM var byte
KK VAR BYTE

symbol DATb = portb.0
symbol STLb = PORTB.1
SYMbol CLKb = portb.2

peek_ind var word
setoff_peek var word
setoff_peek = $6100

peek_data0 var byte
peek_data1 var byte
peek_data2 var byte
peek_data3 var byte
peek_data4 var byte
peek_data5 var byte
peek_data6 var byte
peek_data7 var byte
peek_data8 var byte

peek_d0 var byte
peek_d1 var byte
peek_d2 var byte
peek_d3 var byte
peek_d4 var byte
peek_d5 var byte
peek_d6 var byte
peek_d7 var byte

ic1 VAR BYTE 'data display in each matrix

rowb var byte[8]
' row scan set up
rowb[0] = %11111110
rowb[1] = %11111101
rowb[2] = %11111011
rowb[3] = %11110111
rowb[4] = %11101111
rowb[5] = %11011111
rowb[6] = %10111111
rowb[7] = %01111111
'--------------------------------------
gosub peek_data_ini
gosub peek_d_ini

main:
gosub search
goto main
'-------------------------------------
peek_data_ini:

peek_data0 = 0
peek_data1 = 0
peek_data2 = 0
peek_data3 = 0
peek_data4 = 0
peek_data5 = 0
peek_data6 = 0
peek_data7 = 0
peek_data8 = 0

return
'--------------------------------------

peek_d_ini:

peek_d0 = 0
peek_d1 = 0
peek_d2 = 0
peek_d3 = 0
peek_d4 = 0
peek_d5 = 0
peek_d6 = 0
peek_d7 = 0

return
'-------------------------------------------
search:
for mm= 0 to 5 'store 6 data colum into array peek_data
peek_ind = setoff_peek + mm ' read data from flash mem.
peekcode peek_ind, peek_data8
gosub shift 'shift data into 8 col
gosub display 'display dat a on screen
next
return
'--------------------------------------

shift: 'full screen load 8 collums

peek_data0 = peek_data1
peek_data1 = peek_data2
peek_data2 = peek_data3
peek_data3 = peek_data4
peek_data4 = peek_data5
peek_data5 = peek_data6
peek_data6 = peek_data7
peek_data7 = peek_data8

return

'------------------------------------------

copy: 'COPY DATA INTO TEMP. FILE

peek_d0 = peek_data0
peek_d1 = peek_data1
peek_d2 = peek_data2
peek_d3 = peek_data3
peek_d4 = peek_data4
peek_d5 = peek_data5
peek_d6 = peek_data6
peek_d7 = peek_data7

return
'-------------------------------------------

load_file:

asm ;'PROJECT DOWN
RRCF _peek_d7,1
RLCF _ic1,1
RRCF _peek_d6,1
RLCF _ic1,1
RRCF _peek_d5,1
RLCF _ic1,1
RRCF _peek_d4,1
RLCF _ic1,1
RRCF _peek_d3,1
RLCF _ic1,1
RRCF _peek_d2,1
RLCF _ic1,1
RRCF _peek_d1,1
RLCF _ic1,1
RRCF _peek_d0,1
RLCF _ic1,1
endasm

return
'---------------------------------------
display:
call peek_d_ini
for w = 0 to 15 '
call copy
for kk = 0 to 7 'display on the screen
call load_file
shiftout datb,clkb,0,[ic1,rowb[kk]]'
stlb = 1: pauseus 5: stlb = 0
pauseus 300
datb = 0

next
next
return

'------------------------------------------
end

Pokecode @$6100, $00 ,$1C ,$22 ,$24 ,$3E, $00 'a 0

Demon
- 27th May 2013, 20:04
If this is your first time with an 18F4550, start simple. Blink the 8 LEDs manually first. I have PBP v2.60c, this example is a start (CONFIGs in PBP 3.0 is slightly different):

http://www.picbasic.co.uk/forum/showthread.php?t=17192&p=116630#post116630

Set your CONFIG within your code, we can't see what you set using your programmer.

It's also a good idea to have your DEFINES at the top.

Robert

MINHLE
- 28th May 2013, 01:20
thank for ur words.

i did try bare pic18f4550, it runs well, and letters moving smothly. but when i add 595 shift register, the output is double and uncontrolable i.e. letter a, the result is 2 a,

the thinh that i make some change in the .inc file. it does not solve the problem. st wrong in my program. i tried to narrow down the problem. then see that the issue comes from the scan subroutine (tried it by directing pic18f to control the matrix display (without 595) i.e clear scan port after each scanning). but in this program i cannot.

note that the program runs well with pic16f877a and other pic16f's
regards,

Normnet
- 28th May 2013, 12:37
MINHLE

From the 18F4550 data sheet:
Digital input RC5 and RC4 are only available as port pins
when the USB module is disabled (UCON<3> = 0).

Unlike other PORTC pins, RC4 and RC5 do not have
TRISC bits associated with them. As digital ports, they
can only function as digital inputs.


Norm

MINHLE
- 28th May 2013, 13:26
thanks Norm,
i see it now, but in the program portC does not service. (PORTB.0,1,2 FOR DATA, LATCH AND CLK)
after several tests, i found that problem comes from peekcode.
direct input data to the 595, output is ok. but when i read data from flash memory by PEEKCODE, the problem appears.

READING data from flash memory - BYTE
WRITING data to flash memory - WORD

I attempted to isolate lower byte of data (word) reading from flash memory, it does not solve the issue

(note that changing osc configuration in the .inc does not effect the result)

in the section 5.6 (PBP REERENCE MANUAL) concerning POKECODE

"Note that POKECODE is a specialized command intended for use in
circumstances under which standard methods won't serve. LOOKUP
and LOOKUP2 are usually a better choice for constructing lookup
tables in code space"
REGARDS