Note: On a Power-on Reset, RB4:RB0 are
configured as analog inputs by default and
read as ‘0’; RB7:RB5 are configured as
digital inputs.
By programming the Configuration bit,
PBADEN, RB4:RB0 will alternatively be
configured as digital inputs on POR.
There are several possible issues:
1. Have you disabled the ADCs on RB4:RB0?
2. RB7:RB6 are used for debugging. Have you disable debugging via configuration bits?
3. RB7:RB4 do have the interrupt on change feature and RB3:RB0 have external interrupt features.
Please post your code, so that one of us can examine it and advise you further. A schematic of your circuit was help as well.
BigDog
void PORTSsetup(void);
void LCDsetup(void);
void main() {
PORTSsetup();
LCDsetup();
while(1) {
Lcd_Custom_Out(1,1,"TEST");
}
}// end main
void PORTSsetup() {
ADCON1 = 0xFF;
TRISB = 0x00;
}// end PORTSsetup
void LCDsetup() {
Lcd_Custom_Config(&PORTB, 7, 5, 4, 3,&PORTB, 1, 0, 2);
Lcd_Custom_Cmd(LCD_CLEAR);
Lcd_Custom_Cmd(LCD_CURSOR_OFF);
}// LCDsetup
Simulators don't always incorporate all the hardware quirks (LCD delays are one of them).
Do you leave enough time for LCD to power-up (about 30ms should be more than enough), and also between the commands (or sample D7).
Use LATB for output instead of PORTB (that should be used for input).
I thought ADCON1 0xFF would turn off everything.
The LCD's output is 2 rows of black figures.
Actually ADCON1 = 0x0F would effectively turnoff the A/D on AN12:AN0 or you could set the configuration bit PBADEN = OFF to have RB3:RB0 configured as digital I/O on POR.
The black squares usually indicated a LCD initialization problem. Or I just noticed you do not have a proper contrast control setup for Vee, I would recommend using a 10KΩ Pot with the wiper arm attached to Vee or in a pinch you could use two 5KΩ resistors to bias the Vee. Improper contrast control can result in the appearance of the "black squares."
BigDog
AN12:AN0 means analog inputs from AN12 to AN0... these are multiplexed over PORTA and PORTB pins (check the PIN Diagrams in datasheet on page 4).
PBADEN is set during programming. In MikroC go to Project -> Edit Project. Setting "PORTB A/D" to "Disable" will turn of PBADEN.
Also check that you set the correct frequency. If you are using PLL, set freq*4 so that MikroC can calculate proper timings for the display.
You should try setting some LEDs on PORTB instead of LCD and just do a simple flashing loop to make sure the output is working fine (or check with multimeter of you don't have LEDs nearby). If that works fine, concentrate on the the wiring and software.
void PORTSsetup(void);
void LCDsetup(void);
void main() {
PORTSsetup();
LCDsetup();
while(1) {
Lcd_Custom_Out(1,1,"TEST");
}
}// end main
void PORTSsetup() {
ADCON1 = 0xF;
}// end PORTSsetup
void LCDsetup() {
Lcd_Custom_Config(&PORTB, 7, 5, 4, 3,&PORTB, 1, 0, 2);
Lcd_Custom_Cmd(LCD_CLEAR);
Lcd_Custom_Cmd(LCD_CURSOR_OFF);
}// LCDsetup
This is commonly because of improper contrast setting.The LCD's output is 2 rows of black figures.
You can turn off / disable the analogue circuitry connected to all the analogue inputs by writingBy the way, is there another to turn them off by hard coding it?
ADCON1=0xFF
ADON_bit = 0;
You said:
This is commonly because of improper contrast setting.
https://www.edaboard.com/threads/233352/#post996761
https://www.edaboard.com/threads/194246/#post824737
https://www.edaboard.com/threads/194246/
I suggest you connect a 5k or 10k pot, with one leg going to +5V, the other to ground and the wiper to pin 3 of the LCD. Then adjust the pot until you see something on the screen and the squares disappear. If, however, you have all the connections right and this still doesn't give proper display, then it could be for other reasons.
If you wrote ADCON1=0xFF, that should do it. It disables the ADC analogue circuitry on each of the analogue input pins.
You can turn off / disable the analogue circuitry connected to all the analogue inputs by writingYou can then turn the ADC off by writingCode:ADCON1=0xFF
That should be enough. In fact, even if you don't have the ADC turned off (but you probably will have), AN0:AN12 pins will still be digital.Code:ADON_bit = 0;
Hope this helps.
Tahmid.
ADCON1 = 0xFF;
ADON_bit = 0;
INTCON = 0;
So, in your code, add these:
Set PBADEN off. Turn debug off.Code:ADCON1 = 0xFF; ADON_bit = 0; INTCON = 0;
These were all mentioned in previous posts. I'm summarizing it here for you, because right now, I can't think of another reason for it not to work on PORTB if it works on PORTC.
ADCON0.ADON = 0;
ADCON0.F0 = 0;
ADON_bit is the bit ADON (bit 0 of ADCON0). If it doesn't work, writeorCode:ADCON0.ADON = 0;
Setting ADON to 0 turns ADC off.Code:ADCON0.F0 = 0;
Hope this helps.
Tahmid.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?