CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

More PIC18 DMA woes

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PeterStr



Joined: 21 Jan 2026
Posts: 3

View user's profile Send private message AIM Address

More PIC18 DMA woes
PostPosted: Mon Mar 09, 2026 7:55 pm     Reply with quote

Trying to wrap my head around the way to set up the PIC18's (PIC18F05Q20, namely) DMA to work with the I2C peripheral to handle refreshing of an LCD screen buffer in the background. However, can't figure out the proper way to set it all up. I wrote a simple test case to see if I can get a single short packet sent over the I2C bus, but nothing happens. I understand that somehow an initial trigger needs to be fired in order to start DMA transfer. I was intending to use i2c_start() for such purpose, which would assert the first IF flag to get things going. Turns out, the PIC18's I2C peripheral does not support any I2C functions other than i2c_transfer() Sad
Here's the code for the test case:
Code:

#include <main.h>

void main()
{
   int8 TestStr[] = {0x7A, 0x60, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
   
   setup_dma(1, DMA_TRIGGER_I2C1TX, DMA_TRIGGER_NONE);
   dma_start(1, (DMA_SOURCE_ADDR_IS_SFR_GPR | DMA_INC_SOURCE_ADDR|DMA_DEST_ADDR_UNCHANGED | DMA_ONE_SHOT_FROM_SOURCE_COUNT | DMA_HW_TRIGGER_STARTS_XFER), &I2C1TXB, TestStr, 1, 8);
   dma_go(1);

   while(TRUE)
   {
      //TODO: User Code
   }
}


and this is the header:
Code:

#include <18F05Q20.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS_8MHZ                  //Crystal osc <= 8MHz
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BBSIZ128                 //128 words Boot block size

#pin_select SDA1=PIN_C1
#pin_select SCL1=PIN_C0

#use delay(internal=8MHz)
#use i2c(Master,Fast,sda=PIN_C1,scl=PIN_C0)

#byte I2C1TXB = 0x01F0


How do I get this to work? Any help will be greatly appreciated.

Peter.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group