• AVR Freaks

Hot!SAM E70 Ultra TWI slave example

Author
Xelrebrus
New Member
  • Total Posts : 22
  • Reward points : 0
  • Joined: 2010/08/08 22:39:13
  • Location: 0
  • Status: offline
2020/11/28 16:07:41 (permalink)
0

SAM E70 Ultra TWI slave example

I'm trying to get a TWI slave example setup on my SAM E70 Ultra board using the harmony 3 drivers for the TWIHS0. I'm stumbling through this and I tried following the flowchart for slave read reception in the SAM E70 Manual but when i try to use my known working I2C master program the TWI slave holds the SDA low and won't process. Any insight or example code that I can compare it to would be helpful. Here's my code. 
 
void I2C_Address_Manager_tasks(void)
{
//pg 1081 sam e70 manual
uint8_t SVACC = ((TWIHS0_Module->TWIHS_SR & TWIHS_SR_SVACC_Msk)>>4);
uint8_t GACC = ((TWIHS0_Module->TWIHS_SR & TWIHS_SR_GACC_Msk)>>5);
uint8_t SVREAD = ((TWIHS0_Module->TWIHS_SR & TWIHS_SR_SVREAD_Msk)>>3);
uint8_t TXCOMP = TWIHS0_Module->TWIHS_SR & TWIHS_SR_TXCOMP_Msk;

uint8_t TXRDY = ((TWIHS0_Module->TWIHS_SR & TWIHS_SR_TXRDY_Msk)>>2);
uint8_t RXRDY = ((TWIHS0_Module->TWIHS_SR & TWIHS_SR_RXRDY_Msk)>>1);

uint32_t receive_buffer[10]={'0','0','0','0','0','0','0','0','0','0'};
uint8_t x=0;
uint32_t null;

if(SVACC==1)
{
while (TXCOMP==0)
{
if (GACC==0)
{
if(SVREAD==1)
{
if (TXRDY==1)
{
TWIHS0_Module->TWIHS_THR=1;
null=TWIHS0_Module->TWIHS_RHR;

}
}
else

if (RXRDY==1)
{
receive_buffer[x]=TWIHS0_Module->TWIHS_RHR;
x++;
}
}
}


TXCOMP = TWIHS0_Module->TWIHS_SR & TWIHS_SR_TXCOMP_Msk;
}
}

if (receive_buffer[0]==0&& null==0)
{
return;
}
}
 
#1

3 Replies Related Threads

    Murton Pike Systems
    Super Member
    • Total Posts : 151
    • Reward points : 0
    • Joined: 2020/09/10 02:13:01
    • Location: 0
    • Status: offline
    Re: SAM E70 Ultra TWI slave example 2020/11/28 16:20:07 (permalink)
    0
    I have used the SAM E70 for a usb oscillloscope project and had nothing but problems right from the start.
    Even getting the basic power supply pins connected right was a major exercise.
    I couldnt get USB to work on first pcb.
    Put in a ticket and Microchip told me the SAM E70 I used wont do usb as its not 100 pin.
    Apparently I have to ignore advertisements and data sheet saying it does do usb and read the errata sheet.
    Then I was told to set peripheral wait states to 6. Why doesnt Harmony default to that ?
    Then I couldnt get PWM to work and put in a ticket. Been a month and got no reply on that.
    Tried programmable peripheral clock to get PWM instead and that crashes above 12MHz.
    So gone back to the PIC's.
    A lot of wasted time and money.
     
    post edited by Murton Pike Systems - 2020/11/28 16:21:54
    #2
    mbrowning
    USNA79
    • Total Posts : 1850
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: online
    Re: SAM E70 Ultra TWI slave example 2020/11/28 16:28:15 (permalink)
    4 (1)
    nigelwright7558
    Apparently I have to ignore advertisements and data sheet saying it does do usb and read the errata sheet.
    I think you might have these in the wrong order of priority.
     
    #3
    Murton Pike Systems
    Super Member
    • Total Posts : 151
    • Reward points : 0
    • Joined: 2020/09/10 02:13:01
    • Location: 0
    • Status: offline
    Re: SAM E70 Ultra TWI slave example 2020/11/28 16:32:38 (permalink)
    0
    mbrowning
    I think you might have these in the wrong order of priority.
     

     
     
    I have only been caught out once with PIC's.
    I was using PIC32mx230 series.
    I upgraded to a faster PIC32MX274.
    Microchip in their wisdom decided on the faster 274 that RB4 was no longer an output !
    So got pcb's made and had to put links on them to fix the problem.
     
     
    #4
    Jump to:
    © 2021 APG vNext Commercial Version 4.5