View previous topic :: View next topic |
Author |
Message |
sv_shady
Joined: 07 Mar 2008 Posts: 28
|
Question for 18F4431 and SSP interrupt |
Posted: Tue Apr 15, 2008 1:31 am |
|
|
I need the INT1 and INT2 pins of the PIC so I need the SDA and SCL pins of the SSP module to be multiplexed with the D2 and D3 pins of the controller. But when I set SSP_RD fuse and make the needed changes in the hardware the PIC doesn't go in the interrupt routine for SSP activity. But when I use the C4 and C5 pins everything works fine. Do you have any ideas ? I don't think that any piece of code is needed, but if i am wrong tell me and will post the source. |
|
|
Ttelmah Guest
|
|
Posted: Tue Apr 15, 2008 4:30 am |
|
|
The fuses appear to correctly work.
I'd look carefully at the TRIS. By default, CCS handles the TRIS settings for you. I'd suspect that setting the fuse correctly moves the lines, but CCS, is not quite 'smart enough', and is still handling the TRIS on the other register, so that the values are not set correctly for the I/O pins when used on the second port. The data sheet is also 'poor' in this regard, since it only gives the settings for the default 'portC' operation. You should write down which pins are involved, wich way the TRIS has to be set on each, and try manually setting them to these values. I suspect it'll then start working.
Best Wishes |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
|
sv_shady
Joined: 07 Mar 2008 Posts: 28
|
|
Posted: Tue Apr 15, 2008 6:50 am |
|
|
@Ttelmah I will try it as soon as I have some time.
@PICoHolic What do you mean with "I had to configure I2C manually" ? |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Tue Apr 15, 2008 7:30 am |
|
|
Quote: | @PICoHolic What do you mean with "I had to configure I2C manually" ? |
Code: |
void InitI2CSlave(void)
{
set_tris_c(0xB8);
SSPSTAT = 0x00;
SSPADD = 0xE0;
SSPCON = 0x36;
}
|
|
|
|
sv_shady
Joined: 07 Mar 2008 Posts: 28
|
|
Posted: Tue Apr 15, 2008 2:53 pm |
|
|
I have tried to set the needed TRISD bits, but there was no result. I don't want to set it manually. If I have to do it I'd better use pure assembler, working with bits and bytes and writing tons of code just to use the needed pins of the I2C module. But there are many reasons not to do it...Is this bug fixed in newer or older versions or I should report to CCS ? |
|
|
Matro Guest
|
|
Posted: Wed Apr 16, 2008 1:30 am |
|
|
My advice would be to very carefully read the datasheet sections about :
- SSP overview
- I²C
- GPIO (only the 2 concerned pins)
And also to look for a silicium errata on Microchip website.
Matro. |
|
|
sv_shady
Joined: 07 Mar 2008 Posts: 28
|
|
Posted: Wed Apr 16, 2008 1:59 am |
|
|
I don't think that reading the datasheet carefully would help. Because this is compiler bug, the SSP module works fine when using PortC pins. I have tried to set SSPMX bit manually in the CONFIG3H, but there was no result. |
|
|
Matro Guest
|
|
Posted: Wed Apr 16, 2008 2:25 am |
|
|
A simple question :
Did you have in your code the following line?
And could you confirm that the following one is NOT present?
Matro. |
|
|
sv_shady
Joined: 07 Mar 2008 Posts: 28
|
|
Posted: Wed Apr 16, 2008 2:39 pm |
|
|
Yes I DO have this line... Here is the .h file of my project Code: | #include <18F4431.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed osc with HW enabled 4X PLL
#FUSES NOPROTECT //Code not protected from reading
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV27 //Brownout reset at 2.7V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOWINEN //WDT Timer Window Disabled
#FUSES T1LOWPOWER //Timer1 low power operation when in sleep
#FUSES HPOL_HIGH //High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)
//PWM module high side output pins have active high output polarity
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES LPOL_HIGH //Low-Side Transistors Polarity is Active-High (PWM 0,2,4 and 6)
//PWM module low side output pins have active high output polar
#FUSES PWMPIN //PWM outputs disabled upon Reset
#FUSES MCLR //Master Clear pin enabled
#FUSES FLTAC1 //FLTA input is multiplexed with RC1
#FUSES SSP_RD //SCK/SCL=RD3, SDA/SDI=RD2, SDO=RD1
#FUSES PWM4B5 //PWM4 output is multiplexed on RB5
#FUSES EXCLKC3 //TMR0/T5CKI external clock input is muliplexed with RC3
#use delay(clock=10000000)
#use i2c(Slave, sda=PIN_D2,scl=PIN_D3,force_hw,address=0x10)
|
I have read all the information, concerning the problem, which I could find before writing this post. |
|
|
|