[sdiy] Keyboard with PIC microcontroller

Fredrik Carlqvist Fredrik.Carlqvist at iar.se
Fri Aug 26 11:31:12 CEST 2005


Hi!

Just an addition: If you are using one of the larger PIC derivatives
(16F877A etc.) with RAM in banks 2 or 3, you also need to set the IRP
bit (bit 7) in the STATUS register. It selects banks for the FSR
register. Set it to 1 if you are accessing bank 2 or bank 3, otherwise
reset it to 0. 

Good luck with the project!
 

Fredrik C


> -----Original Message-----
> From: owner-synth-diy at dropmix.xs4all.nl 
> [mailto:owner-synth-diy at dropmix.xs4all.nl] On Behalf Of 
> simon.oo.o at xs4all.nl
> Sent: den 26 augusti 2005 09:18
> To: synth-diy at dropmix.xs4all.nl
> Subject: Re: [sdiy] Keyboard with PIC microcontroller
> 
> Hi Stefano,
> 
> kernel255\.mailinglis zei:
> > Hi all,
> > I have developed a small circuit to read keys of a keyboard 
> with a PIC
> > microcontroller. I have already developed the hardware, but 
> I have some
> > problem in developing the software with Assembler. I 
> checked the PIC's CPU
> > instructions and I haven't found any instruction to do 
> indirect addressing
> > or indexed addressing; I explain it by a simple C example:
> >
> > #define BufferSize 5
> >
> > char buffer[BufferSize],data,i;
> > char *bufferPtr = buffer;
> >
> > for(i=0;i<BufferSize;i++)
> > {
> >     data = *(bufferPtr+i);
> >     /* ... do something on data ... */
> > }
> >
> > What I'm not able to do with PIC Assembler is to have a 
> pointer to memory,
> > increment it, and read or write the memory location pointed by it. I
> > searched for a special register to do stuff like these (as 
> append for
> > other CPUs) but I haven't found it.
> 
> The index register in a PIC is called FSR.
> The data it points to can be read and written via INDF.
> 
> Example:
> 
>    movlw  bufstart     ; bufstart defined as start address of buffer
>    movwf  FSR          ; SFR now points to start of buffer
>    movlw  d'5'
>    movwf  count
> Loop:
>    movfw  INDF         ; get next byte
>    call   Putchar      ; (or something)
>    incf   FSR          ; increase pointer
>    decfsz count
>    goto   Loop
> 
> 
> Vriendelijke groet,
> 
> Simon Brouwer
> --> nl.openoffice.org <--
> 
> 




More information about the Synth-diy mailing list