Searching \ for '[PIC] Losing my mind' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Losing my mind'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Losing my mind'
2011\10\24@134455 by PICdude

flavicon
face
Can I borrow your eyes please?  Porting some assembly code to a  18F23K22 and getting not getting results I expect.  Specifically, I  can't seem to get RA2 to work as a digital input.  Yeah, I know, I  should be ashamed of myself.

So I've whittled down the code as much as I can and now realize that  RA0, RA1, etc are also not working as digital inputs.  At this point,  either I'm missing something simple, or it may be a hardware issue.   But RA0/AN0 & RA1/AN1 work as analog inputs, so I'm reluctant to  accept that.  And I'm also seeing the same problem with RE3/Mclr as a  digital input.  Hardware issue requires ordering another part and then  swapping it (SMD), so thought I'd post here first to be sure.  FWIW,  I've verified that the external voltage applied to the RA2 etc pins  are changing as required.

This is the whittled-down code...

       LIST P=PIC18F23K22
       INCLUDE "p18f23k22.inc"
       ERRORLEVEL -302
       CONFIG FOSC=INTIO67
       CONFIG PLLCFG=OFF
       CONFIG PRICLKEN=ON
       CONFIG FCMEN=OFF
       CONFIG IESO=ON
       CONFIG PWRTEN=ON
       CONFIG BOREN=ON
       CONFIG BORV=285
       CONFIG WDTEN=OFF
       CONFIG PBADEN=OFF
       CONFIG MCLRE=INTMCLR
       CONFIG STVREN=OFF
       CONFIG XINST=OFF
       CONFIG DEBUG=OFF
       CONFIG CP0=OFF
       CONFIG CP1=OFF
       CONFIG CPB=OFF
       CONFIG CPD=OFF
       CONFIG WRT0=OFF
       CONFIG WRT1=OFF
       CONFIG WRTC=OFF
       CONFIG WRTB=OFF
       CONFIG WRTD=OFF
       CONFIG EBTR0=OFF
       CONFIG EBTR1=OFF
       CONFIG EBTRB=OFF


;----- Veriables -----


;----- Code section -----
       ORG        0x0000
       goto        Init

       ORG        0x0008

       ORG        0x0018

;---------------------------------------------------------------------
;  Initialization section...
;---------------------------------------------------------------------

Init:
       clrf        BSR
       clrf        INTCON
       clrf        RCON                        ; IPEN = 0

       ;----- Setup oscillator -----
       movlw        B'01100011'                ; 8 Mhz, internal osc.
       movwf        OSCCON

       ;----- Setup ports -----
       movlw        B'11011111'                ; RA5 = column output
       movwf        TRISA
       movlw        B'00000000'
       movwf        TRISB                        ; All outputs (display 1 segments)
       movlw        B'00000000'
       movwf        TRISC                        ; All outputs (display 2 segments)
       movlw        B'00001000'
       movwf        TRISE                        ; Should not need this

       clrf        ANSELA                        ; All digital
       clrf        ANSELB                        ; ...
       clrf        ANSELC                        ; ...

       movlw        B'00000100'
       movwf        CM1CON0                        ; Comparators off
       movwf        CM2CON                        ; ...
       clrf        CM2CON1                        ; ...

       clrf        VREFCON1                ; Turn off DAC

       clrf        ADCON0
       clrf        ADCON1
       clrf        ADCON2

       movlw        B'10101010'                ; Testing
       movwf        PORTB
InitDone:


;---------------------------------------------------------------------
;  Main code loop...
;---------------------------------------------------------------------

MainLoop:
       movlw        B'00100000'
       movwf        PORTA                        ; LED column on

       movf        PORTA,W                        ; Read all port-A inputs
       movwf        PORTC                        ; Show on LED segments.
MainLoopDone:
       goto        MainLoop

       end

2011\10\24@165025 by IVP

face picon face
> MainLoop:
> movlw B'00100000'
> movwf PORTA ; LED column on

movwf LATA

> movf PORTA,W ; Read all port-A inputs
> movwf PORTC ; Show on LED segments.

movwf LATC

> MainLoopDone:
> goto MainLoop
>
> end

2011\10\24@165807 by Electron

flavicon
face

Have you checked the disassembly? Maybe a compiler bug?


At 22.50 2011.10.24, you wrote:
{Quote hidden}

>

2011\10\24@165852 by Electron

flavicon
face

PS: sorry this reply was meant for another thread :P





Have you checked the disassembly? Maybe a compiler bug?


At 22.50 2011.10.24, you wrote:
{Quote hidden}

>

2011\10\24@194553 by PICdude

flavicon
face
Can't see that (latch) being the reason, but tried anyway and it still  does not work.  If I did...

       movlw        B'10101010'
       movwf        PORTC

....instead of...

       movf        PORTA,W
       movwf        PORTC

.... it (upper with literal) works.  Implying that it's reading from  PORTA is the problem.

Cheers,
-Neil.



Quoting IVP <spam_OUTjoecolquittTakeThisOuTspamclear.net.nz>:

{Quote hidden}

>

2011\10\24@194708 by PICdude

flavicon
face
Disassembly (I had checked the .lst file) is correct.  My pickit2 is  not supported for debugging this chip from MPLAB, but that might've  been helpful.

Cheers,
-Neil.



Quoting Electron <.....electron2k4KILLspamspam@spam@infinito.it>:

{Quote hidden}

>> -

2011\10\24@200746 by IVP

face picon face
> Can't see that (latch) being the reason, but tried anyway and it
> still does not work

I thought it might. Not so long ago I mistakenly used PORT
instead of LAT and spent some time trying to figure out why
'my stupid PIC doesn't work'. For the life of me I can't remember
the piece of code or I'd show you. I do recall it wasn't that
different from your problem

IMHO it's still good practise to use LAT for out and PORT for in

Are the PORTA pins floating ?

Jo

2011\10\24@211603 by Scott

picon face
> So I've whittled down the code as much as I can and now realize that
> RA0, RA1, etc are also not working as digital inputs.  At this point,
> either I'm missing something simple, or it may be a hardware issue.
> But RA0/AN0 & RA1/AN1 work as analog inputs, so I'm reluctant to
> accept that.  And I'm also seeing the same problem with RE3/Mclr as a
> digital input.  Hardware issue requires ordering another part and then
> swapping it (SMD), so thought I'd post here first to be sure.  FWIW,
> I've verified that the external voltage applied to the RA2 etc pins
> are changing as required.

Does it work in the simulator (i.e. are all SFRs getting set)?

2011\10\25@003632 by PICdude

flavicon
face
Prior to having built in latches (16F stuff), I developed a habit of  using registers as latches.  Any time I make a change to one of those  registers, I update to the port.

RA0,1 are pulled up (to 5Vdd) with 2k resistors.  RA2 is pulled up  with a 100k, and has a momentary pushbutton to ground.  Verified RA2  changes between 5V and ground with switch.

Cheers,
-Neil.



Quoting IVP <joecolquittspamKILLspamclear.net.nz>:

{Quote hidden}

>

2011\10\25@004922 by PICdude

flavicon
face
Will have to try that.  Last time I used that stimulus thing, I got  quite frustrated.  That was a few years ago, so will have to re-figure  this out.

I was actually thinking someone would've told me something about a  peripheral mux'ed on port-A that I need to turn off.

Cheers,
-Neil.


Quoting Scott <.....goldscottKILLspamspam.....gmail.com>:

> Does it work in the simulator (i.e. are all SFRs getting set)?
>

2011\10\25@012713 by IVP

face picon face
I note that in the .inc file there are entries for alternative (mis)spellings

CM12CON          EQU  H'0F77'  ;this one seems odd
CM2CON1          EQU  H'0F77'
CM2CON           EQU  H'0F78'
CM2CON0          EQU  H'0F78'
CM1CON           EQU  H'0F79'
CM1CON0          EQU  H'0F79'

Clutching at straws - something not compiling the way you thought ?

> ORG 0x0018
>
> ;---------------------------------------------------------------------
> ;  Initialization section...
> ;---------------------------------------------------------------------
>
> Init:

Clutching at straws (supplemental) - 0x0018 is an IRQ vector. 0x0020 ?

Joe

2011\10\25@071308 by Electron

flavicon
face

Do you have a spare, unused chip to test?

I recall that few months ago had damaged a dsPIC and it worked well but
for some functions, then I used a new, fresh chip and it magically worked..
no bugs, only damaged chip.

Maybe worth a try! ;)



At 01.47 2011.10.25, you wrote:
{Quote hidden}

>>> --

2011\10\25@083946 by David Novak

picon face
Make sure you have good ground connections.


On 10/25/2011 1:27 AM, IVP wrote:
{Quote hidden}

2011\10\29@172028 by PICdude

flavicon
face
I'm back, and working on this issue again.  Still not working, but  some extra and interesting data...

(1) I did see those alternate comparator-register names in the .inc  file, but all seem to be set correctly, as per addresses stated in  datasheet.

(2) Also verified the addresses for DAC.

(3) The datasheet says for the PORTA<2> pin in input mode:  "disabled  when analog input enabled; disabled when DACOUT enabled".  I've  explicitly disabled both the A/D and DAC.

(4) I've put org 0x0020 before Init, to verify interrupts are not  causing that issue.

(5) Grounds are good, and I've verified with a multimeter that the  voltage at RA2 changes from 5V to 0V with the switch is pressed.

(6) I've upgraded to the latest MPLAB 8.80 (was 8.66).

(7) The biggie:  I have tried a new PIC23K22 on a new PCB, laid out  differently, but same circuit.  It still does not work.  So it has to  be a firware/operator error.

I've also noticed that even with config set such that MCLR is  disabled, it seems to be enabled still.  I'm seeing the config bits  set correctly in the Pickit2 programmer software.

So now I'm stumped.  While I continue to scratch my head over this,  I'll see if an FAE can figure this out, but that means more delays.

Cheers,
-Neil



Quoting IVP <joecolquittspamspam_OUTclear.net.nz>:

{Quote hidden}

>

2011\10\29@191539 by Chris Roper

picon face
Hi,

> (3) The datasheet says for the PORTA<2> pin in input mode:  "disabled
> when analog input enabled; disabled when DACOUT enabled".  I've
> explicitly disabled both the A/D and DAC.

Sorry to Hijack the thread, but I didn't realize there were PIC's with DAC's.
Are they available in all families or is it a new branch?

I jumped from PIC16 to PIC32 so am not up to date on anything in between.

Cheers
Chris

2011\10\29@193021 by jim

flavicon
face
AFAIK, the DAC is only a 6 bit affair that is used in conjunction with the
Comparator Module to set the trigger level.


{Original Message removed}

2011\10\29@194300 by IVP

face picon face
> PIC's with DAC's.
> Are they available in all families or is it a new branch?

There are several with DACs. eg 18F23K22 5-bit, dsPIC30 10-bit,
and dsPIC33 stereo audio DAC. Also the 4-bit Vref of those with
comparators

Joe

2011\10\29@200732 by Chris Roper

picon face
Thanks Guys,

I will take a look at the dsPIC family, I need it for audio stuff so
that is probably the way to go.
Abnormal programming will resume :) sorry for the detour.


On 30 October 2011 01:42, IVP <@spam@joecolquittKILLspamspamclear.net.nz> wrote:
>> PIC's with DAC's.
>> Are they available in all families or is it a new branch?
>
> There are several with DACs. eg 18F23K22 5-bit, dsPIC30 10-bit,
> and dsPIC33 stereo audio DAC. Also the 4-bit Vref of those with
> comparators
>
> Joe
>
>
>

2011\10\29@201923 by Jan-Erik Soderholm

face picon face


IVP wrote 2011-10-30 01:42:
>> PIC's with DAC's.
>> Are they available in all families or is it a new branch?
>
> There are several with DACs. eg 18F23K22 5-bit, dsPIC30 10-bit,
> and dsPIC33 stereo audio DAC. Also the 4-bit Vref of those with
> comparators
>
> Joe
>
>

Many newer 12F and 16F PICs has a 5-bit DAC including the
8-pin PIC12F1501 and the series of PIC16F15xx. And there are
a number of future 16F's with full 8-bit DAC

2011\10\29@213232 by IVP

face picon face
> So now I'm stumped

You lost your legs too ? Not been your month has it ...

Good luck with problem. Please let us know how it works out

Jo

2011\10\29@213804 by PICdude

flavicon
face
> Sorry to Hijack the thread, but ...

But yet you did. :)

More... (looser matching)
- Last day of these posts
- In 2011 , 2012 only
- Today
- New search...