Dear All,
This is the thread I will be sticking with, with regard to this project I am working on from now on. I have included a picture of the dev board I have built and the schematic as well.
Some background. I decided to start this project as I needed a function generator for other projects and yes I could actually buy one for a bit of money and no time but I thought what was the fun in that... so my real driver was to learn something... start a challenging project and something might rub off.
There are a number of projects out there on this subject however I chose to base mine on another project which can be found here... It was very good but used two PIC chips and I thought it might be a good idea to work this from just one chip... to this end I have built a development board for which I have included a picture... Further I am including the schematic as well.
All is going fairly well but alas I find myself floundering again.... and again its to do with the interrupt routine.
Here is my current problem...
I have both the keyboard and the encoder working off PORTB. The keyboard connects via RB7-4 to RD7-4 and the encoder attaches to RB0/1.
For the keyboard I have set weak pullups (set in PIC_INT) so when a user presses a button they connect a pin in RB7-4 to a pin in RD7-4 all of which are held to "0".
I have to stress it all works perfectly when I set the inputs for PORTB as B'11110000' in the PIC_INT or (pic initialisation routine) - see below:
HERE IS MY ISSUE:
If I now change the setting of PORTB so it recognises RB0/1 as inputs:
It locks up and does not interrupt for the keyboard. However if I turn the encoder it interrupts perfectly..
I have tried all manner of things to try and get this to work (pretty much the whole of last week) but I cannot figure this out. I even tried to set the PINS RD7-4 high and not set the weak pullups for PORTB and then, in the interrupt set the RD7-4 pins low and then turn on the weak pullups and then test for the key... this also didnt work...
Incidentally, the interrupts are set in the routines:
1.3 EE_FREQ_DOESNT_EXIST
1.4 EE_FREQ_EXISTS
NOTE: if no values are detected in the EEPROM then the encoder interrupt is disabled... that is the encoder is only enabled in EE_FREQ_EXISTS and once the user enters freq the encoder interrupt is enabled. To test this I loaded an frequency into the EEPROM of 100. To do this I set 07 = 0 06 = 0 and 05 = 01. The rest I left as "FF".
From what I see this is all about the interrupt routine (maybe) and you do not have to delve into any of the other code which is now quite long... but works.... I have included the .ASM FILE as well as the three include files.
View attachment FUNCTION GENERATOR 1-3.zip
I am hoping someone might look at the interrupt routine or the PIC_INITALISATION routine and see an obvious problem... its most probably something really simple.
I sincerely hope someone can help me here...
Kind Regards
Simon
This is the thread I will be sticking with, with regard to this project I am working on from now on. I have included a picture of the dev board I have built and the schematic as well.
Some background. I decided to start this project as I needed a function generator for other projects and yes I could actually buy one for a bit of money and no time but I thought what was the fun in that... so my real driver was to learn something... start a challenging project and something might rub off.
There are a number of projects out there on this subject however I chose to base mine on another project which can be found here... It was very good but used two PIC chips and I thought it might be a good idea to work this from just one chip... to this end I have built a development board for which I have included a picture... Further I am including the schematic as well.
All is going fairly well but alas I find myself floundering again.... and again its to do with the interrupt routine.
Here is my current problem...
I have both the keyboard and the encoder working off PORTB. The keyboard connects via RB7-4 to RD7-4 and the encoder attaches to RB0/1.
For the keyboard I have set weak pullups (set in PIC_INT) so when a user presses a button they connect a pin in RB7-4 to a pin in RD7-4 all of which are held to "0".
I have to stress it all works perfectly when I set the inputs for PORTB as B'11110000' in the PIC_INT or (pic initialisation routine) - see below:
Code:
PIC_INIT
clrf STATUS ; DO INITIALIZATION, SELECT BANK 0
clrf INTCON ; CLEAR INT-FLAGS, DISABLE INTERRUPTS
clrf PCLATH ; KEEP IN LOWER 2KBYTE
clrf PORTA ; ALL PORT OUTPUT SHOULD OUTPUT LOW.
clrf PORTB ; ALL PORT OUTPUT SHOULD OUTPUT LOW.
clrf PORTC ; ALL PORT OUTPUT SHOULD OUTPUT LOW.
clrf PORTD ; ALL PORT OUTPUT SHOULD OUTPUT LOW.
clrf PORTE ; ALL PORT OUTPUT SHOULD OUTPUT LOW.
bcf STATUS, RP1 ; FOR BANK 1 RP1=0 RP0=1.
bsf STATUS, RP0 ; SELECT BANK 1.
clrf PORTB ;LATCH ALL LOW.
movlw B'11110000' ;RB4-RB7 INPUTS.
movwf TRISB
movlw B'00000000' ; RD4-7 INPUTS.
movwf TRISD
bcf OPTION_REG, NOT_RBPU
;ENABLE WEAK PULL-UPS.
;ON PORT B.
bcf STATUS, RP1 ; FOR BANK 0 RP1=0 RP0=0.
bcf STATUS, RP0 ; SELECT BANK 0.
bcf STATUS,IRP ;MAKING SURE THAT THE FIRST PAGE OF THE FSR
; IS SELECTED.
return
HERE IS MY ISSUE:
If I now change the setting of PORTB so it recognises RB0/1 as inputs:
Code:
movlw B'111100[COLOR="red"]11[/COLOR]' ;RB4-RB7 INPUTS.
movwf TRISB
It locks up and does not interrupt for the keyboard. However if I turn the encoder it interrupts perfectly..
I have tried all manner of things to try and get this to work (pretty much the whole of last week) but I cannot figure this out. I even tried to set the PINS RD7-4 high and not set the weak pullups for PORTB and then, in the interrupt set the RD7-4 pins low and then turn on the weak pullups and then test for the key... this also didnt work...
Incidentally, the interrupts are set in the routines:
1.3 EE_FREQ_DOESNT_EXIST
1.4 EE_FREQ_EXISTS
NOTE: if no values are detected in the EEPROM then the encoder interrupt is disabled... that is the encoder is only enabled in EE_FREQ_EXISTS and once the user enters freq the encoder interrupt is enabled. To test this I loaded an frequency into the EEPROM of 100. To do this I set 07 = 0 06 = 0 and 05 = 01. The rest I left as "FF".
From what I see this is all about the interrupt routine (maybe) and you do not have to delve into any of the other code which is now quite long... but works.... I have included the .ASM FILE as well as the three include files.
View attachment FUNCTION GENERATOR 1-3.zip
I am hoping someone might look at the interrupt routine or the PIC_INITALISATION routine and see an obvious problem... its most probably something really simple.
I sincerely hope someone can help me here...
Kind Regards
Simon