PDA

View Full Version : 16C55 Problem.



hope_man
- 16th March 2006, 15:05
I'm using a 16c55/RC MCU with a 1k/10pF external RC oscillator. MCLR is not connected. supply is 5v. And the following program is not working. IT compiles fine. and writes fine to the MCU. I'm using PicBasic Pro 2.46 and a 865 Universal device programmer from BK precision with the latest software. HEre is my source. Thanks for helping me.


'0000 = Analog Input Channel 0
'0001 = Analog Input Channel 1
'0010 = Analog Input Channel 2
'0011 = Analog Input Channel 3
'0100 = Analog Input Channel 4
'0101 = Analog Input Channel 5
'0110 = Analog Input Channel 6
'0111 = Analog Input Channel 7
'1000 = Digital Out
'1001 = Digital In
'1010 = Relay Out
'1111 = RESET
'--------------------------------------------------

COMMANDE var PORTA ' Alias du port de commande
DATABUS var PORTB ' Alias du port data (DEBUG inutiliser)
SELECTLINE var PORTC ' Port de selection et d'address

ADC_0 con 0
ADC_1 con 1
ADC_2 con 2
ADC_3 con 3
ADC_4 con 4u
ADC_6 con 6
ADC_7 con 7
DIGITAL_IN con 8
DIGITAL_OUT con 9
RELAY_OUT con 10
RESET con 15

TRISA = %1111 ' PORT A input (Commande)

TRISB = %11111111 ' Port B input (Data DEBUG)

TRISC = %00000000 ' PORT C output (Address,Chip Select)


'Description du bus SELECTLINE
'bit0 = LSB de l'adress du canal de l'ADC
'bit1 = ''
'bit2 = MSB de l'adress du canal de l'ADC
'bit3 = CS de l'ADC
'bit4 = ERROR LINE
'bit5 = CS de DIGITAL_IN
'bit6 = CS de RELAY_OUT
'bit7 = CS de DIGITAL_OUT

loop:
select case COMMANDE
case ADC_0
SELECTLINE = %00001000 ' CANAL 0 , CS ON
case ADC_1
SELECTLINE = %00001001 ' CANAL 1 , CS ON
case ADC_2
SELECTLINE = %00001010 ' CANAL 2 , CS ON
case ADC_3
SELECTLINE = %00001011 ' CANAL 3 , CS ON
case ADC_4
SELECTLINE = %00001100 ' CANAL 4 , CS ON
case ADC_5
SELECTLINE = %00001101 ' CANAL 5 , CS ON
case ADC_6
SELECTLINE = %00001110 ' CANAL 6 , CS ON
case ADC_7
SELECTLINE = %00001111 ' CANAL 7 , CS ON
case DIGITAL_IN
'select DIGITAL IN
SELECTLINE = %00100000
case DIGITAL_OUT
'select DIGITAL OUT
SELECTLINE = %10000000
case RELAY_OUT
'select relay out
SELECTLINE = %01000000
case RESET
'etat nul
SELECTLINE = %00000000
case else
'bit 4 on ERROR
SELECTLINE = %00010000
end select
Goto loop ' repete pour toujours
End

This program uses the table at the beginning as command. They are sent to PORTA which is 4bit, compare the command received in the select case block and then send the output on portc. THIS IS WHAT IT is supposed to do but it does not work.


PLEASE HELP!!!

mister_e
- 17th March 2006, 00:29
What about your Config fuses?

Did you test your stuff with a super duper Led Blinking program first before?

Look Section 4.4 for the R/C choice.. you'll discover some limitations...

La vie est une salope desfois ;)

Ingvar
- 17th March 2006, 10:38
Unless my memory is playing tricks with me, i'd say that you MUST connect MCLR to +5V.

hope_man
- 18th March 2006, 16:15
Yeah.... It works with the MCLR to 5v.... thanx.. I was just so lunatic