Hi.
I encounter an issue with 7 serial 74HC595 that I can't understand.
I talk with them with a PIC18F26K22 in SPI mode. Here is my configuration :
Fosc = 16MHz, 64MHz with PLL activated.
SSP1STAT = 0x40 and SSP1CON1 = 0x20, so
Next, I send it to shift registers as it :
It works well but for some bits, I have also to modify previous one. So I do :
With this associated output, in any cases, it opens the 2 to 6 first outputs of the first shift register while it should not.
If associatedOutput is always 0, it seems to work fine.
I first thought to a memory problem which could modify my array arrOuts during a function call but after many tries, I can't confirm. Working in debug mode with data breakpoints on writing to arrOuts[0][0], it never stops.
I tried not using PLL to run at 16MHz and setting SSP1CON1 to 0x22 for reducing SPI speed to 250Hz with no effects.
There is a 74HC244 activated by Out_CS after the µC to drive the signal after what one connector and the first ShiftRegister.
I've no more ideas about where could be my problem. Could you help me to understand where it could be ?
Maybe modifying the clock polarity, clock edge or data input sample phase but I don't know precisely what should be the effect of these parameters.
Thanks so much for your advices.
I encounter an issue with 7 serial 74HC595 that I can't understand.
I talk with them with a PIC18F26K22 in SPI mode. Here is my configuration :
Fosc = 16MHz, 64MHz with PLL activated.
SSP1STAT = 0x40 and SSP1CON1 = 0x20, so
- Input data sampled at middle of data output time
- Transmit occurs on transition from active to Idle clock state
- No collision, no overflow
- Idle state for clock is a low level
- MasterMode, clock = Fosc/4
Code:
static
char Modif_Output(unsigned char pos, char bOnOff) {
int iOutGroup, iOutBit;
iOutGroup = pos / 8;
iOutBit = pos % 8;
// set and clear corresponding output
arrOuts[iOutGroup][iOutBit] = bOnOff;
return 1;
}
Code:
uint8_t interface_tx(uint8_t data) {
spi_buff = data;
while (!spi_bufFull);
return (spi_buff);
}
void Out_Refresh(void) {
signed char iOutGroup, iOutBit;
Out_CS = 0;
// send 7 x 8 bits one after the other
for (iOutGroup = 6; iOutGroup >= 0; iOutGroup--) {
iOut = 0x00;
for (iOutBit = 7; iOutBit >= 0; iOutBit--) {
iOut <<= 1;
iOut |= arrOuts[iOutGroup][iOutBit];
}
interface_tx(iOut);
}
Out_CS = 1;
}
Code:
void Prepare_Output(void) {
unsigned char outSelect = 0;
char bModif;
// search right output
while (outSelect<cNbOuts) {
if (outToModify == arrOutPosition[outSelect]) {
bModif = Modif_Output(outSelect, bOnOff);
if (associatedOutput) bModif += Modif_Output(outSelect, bOnOff);
break;
}
else outSelect++;
}
if (bModif > 0) Out_Refresh();
}
With this associated output, in any cases, it opens the 2 to 6 first outputs of the first shift register while it should not.
If associatedOutput is always 0, it seems to work fine.
I first thought to a memory problem which could modify my array arrOuts during a function call but after many tries, I can't confirm. Working in debug mode with data breakpoints on writing to arrOuts[0][0], it never stops.
I tried not using PLL to run at 16MHz and setting SSP1CON1 to 0x22 for reducing SPI speed to 250Hz with no effects.
There is a 74HC244 activated by Out_CS after the µC to drive the signal after what one connector and the first ShiftRegister.
I've no more ideas about where could be my problem. Could you help me to understand where it could be ?
Maybe modifying the clock polarity, clock edge or data input sample phase but I don't know precisely what should be the effect of these parameters.
Thanks so much for your advices.
Last edited: