Hi i want to send a array of data through the serial port but when i try to use a pointer to address the array and then write
at start of program tempptr=tempdata;
then
putcUSART(*tempptr);
tempptr++;
it gives a syntax error.
On the other hand tempdata[counter] works fine.
//configure timer1
OpenTimer1(0b10010101);
PIE1bits.TMR1IE = 1; //periferial interupt register, 1 = timer 1 interupt enabled
PIR1bits.TMR1IF = 0; //clears the timer 1 interupt flag
//configure CCP1 for capture, rising edge
CCP1CON = 0b0000101;
//ccp interrupt
if(PIR1bits.CCP1IF == 1)
{
if(PWM1Edge == 1)//if detecting rising
{
interrupttest3++;
PWM1RiseTime = CCPR1;//save the low timer value for the rise time
CCP1CON = 0b0000100;//switch to detect falling edge
PWM1Edge = 0;//switch to indicate falling edge is next
}
else //detecting falling
{
interrupttest2++;
PWM1Width = CCPR1 - PWM1RiseTime;
CCP1CON = 0b0000101;//switch to detect rising edge
PWM1Edge = 1;//switch to indicate rising edge is next
}
interrupttest1++;
PIR1bits.CCP1IF = 0; //clear the flag
}
}
#pragma config OSC = INTIO2, WDT = OFF, LVP = OFF
#include <p18f1320.h>
//set up interrupt
void low_ISR(void);//prototype
#pragma code low_vector = 0x18
void low_interrupt (void){
_asm goto low_ISR _endasm
}
#pragma code
#pragma interrupt low_ISR
//setup pins for PWM input
#define ReceiverPin PORTBbits.RB3
#define ReceiverTris TRISBbits.TRISB3
//PWM capture variables
unsigned int PWM1RiseTime = 0;
unsigned int PWM1Width = 0;
char PWM1Edge = 1;
char test1 = 0;
// Interrupts
void low_ISR(void)
{
test1 = 1;
//ccp interrupt
if(PIR1bits.CCP1IF == 1)
{
PIR1bits.CCP1IF = 0; //clear the flag
if(PWM1Edge == 1)//if detecting rising
{
PWM1RiseTime = CCPR1;//save the low timer value for the rise time
CCP1CON = 0b0000100;//switch to detect falling edge
PWM1Edge = 0;//switch to indicate falling edge is next
}
else //detecting falling
{
PWM1Width = CCPR1 - PWM1RiseTime;
CCP1CON = 0b0000101;//switch to detect rising edge
PWM1Edge = 1;//switch to indicate rising edge is next
}
}
}
void main(void)
{
//set clock to 8 Mhz
OSCCONbits.IRCF0=1;
OSCCONbits.IRCF1=1;
OSCCONbits.IRCF2=1;
//configure timer1
OpenTimer1(0b10010101);
PIE1bits.TMR1IE = 1; //periferial interupt register, 1 = timer 1 interupt enabled
PIR1bits.TMR1IF = 0; //clears the timer 1 interupt flag
//configure CCP1
CCP1CON = 0b0000101; //configure CCP1 for capture, rising edge
ReceiverTris = 1; //set RB3 for input so the capture can work.
//configure ports
ADCON1 = 0xff; //all digital
INTCON2bits.RBPU = 0; //port b weak pullups on
while(1)
{
}
}
INTCONbits.PEIE=1; //enable peripheral ints
PIE1bits.CCP1IE=1; //namely the CCP1 int
INTCONbits.GIE=1; //finally turn them on
PIE1bits.TMR1IE = 1; //periferial interupt register, 1 = timer 1 interupt enabled
PIR1bits.TMR1IF = 0; //clears the timer 1 interupt flag
//Basic configureation of chip periferials
#pragma config OSC = INTIO2, WDT = OFF, LVP = OFF
#include <p18f1320.h>
//setup pins for PWM input
#define ReceiverPin PORTBbits.RB3
#define ReceiverTris TRISBbits.TRISB3
//PWM capture variables
unsigned int PWM1RiseTime = 0;
unsigned int PWM1Width = 0;
char PWM1Edge = 1;
//set up interrupt
void low_ISR(void);//prototype
#pragma code low_vector = 0x08
void low_interrupt (void){
_asm goto low_ISR _endasm
}
#pragma code
#pragma interrupt low_ISR
//debug stuff
char test1 = 0;
char test2 = 0;
void main(void)
{
OSCCON = 0x72; //8MHz clock
while(!OSCCONbits.IOFS); //Wait for OSC to become stable
//configure timer1
OpenTimer1(0b10010101);
PIE1bits.TMR1IE = 1; //periferial interupt register, 1 = timer 1 interupt enabled
PIR1bits.TMR1IF = 0; //clears the timer 1 interupt flag
//configure CCP1
CCP1CON = 0b0000101; //configure CCP1 for capture, rising edge
INTCONbits.PEIE=1; //enable peripheral interrupts
PIE1bits.CCP1IE=1; //enabled CCP1 interrupt
INTCONbits.GIE=1; //enable branching to interrupt
ReceiverTris = 1; //set RB3 for input so the capture can work.
//configure ports
ADCON1 = 0xff; //all digital
INTCON2bits.RBPU = 0; //port b weak pullups on
while(1)
{
}
}
void low_ISR(void)
{
test1 = 1;
//ccp interrupt
if(PIR1bits.CCP1IF == 1)
{
PIR1bits.CCP1IF = 0; //clear the flag
if(PWM1Edge == 1)//if detecting rising
{
PWM1RiseTime = CCPR1;//save the low timer value for the rise time
CCP1CON = 0b0000100;//switch to detect falling edge
PWM1Edge = 0;//switch to indicate falling edge is next
}
else //detecting falling
{
PWM1Width = CCPR1 - PWM1RiseTime;
CCP1CON = 0b0000101;//switch to detect rising edge
PWM1Edge = 1;//switch to indicate rising edge is next
}
}
}
#include<p18f4620.h>
void main(void)
{ unsigned int result;
unsigned int a=0x1018;
unsigned int b=0x0018;
unsigned int ceilingrd=0x1018;
unsigned int ceilingr=0x0018;
unsigned int diff,perc,castingl,castingh;
castingl=(ceilingrd);
castingh=(ceilingrd/256);
diff=ceilingrd-ceilingr;
result=b-a;
perc=(diff/ceilingrd)*100;
while(1);
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?