Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem calling in PIC C18, parameters garbled - using pointers to structures perhaps?
    primarykey
    data
    text
    <p>I am trying to make a fairly simple call using PICC18.</p> <p>Using the MPLAB simulator I am seeing the arguments, even on entry to the function, being completely garbled.</p> <p>I have the following typedef</p> <pre><code>typedef struct { // t_ax25AddressChar callsign[6]; unsigned char callsign[6]; union { struct { unsigned isRepeated:1; // MSB - 1=repeated unsigned reserved:2; // Reserved unsigned ssid:4; // SSID unsigned isLast:1; // LSB - Is the last address }; unsigned char value; } flags; } t_ax25Callsign; </code></pre> <p>(My TODO list includes working out the order I need to specify bitfields)</p> <p>That is embedded in a further struct</p> <pre><code>typedef struct { union { struct { t_ax25Callsign to; t_ax25Callsign from; t_ax25Callsign path[APRS_MAX_REPEATERS]; }; t_ax25Callsign allCallsigns[APRS_MAX_REPEATERS + 2]; } address; // PID and Control are hard coded for APRS const char message[APRS_MAX_MESSAGE_LENGTH + 1]; // null terminated message string } t_aprsPacket; </code></pre> <p>and allocated somewhere in paged RAM (in main.c)</p> <pre><code>#pragma udata static t_aprsPacket s_packet; </code></pre> <p>The method defined in aprs.h</p> <pre><code>extern void aprsMakeCallsignPgm(t_ax25Callsign *buffer, const rom char *callsign, unsigned char ssid); </code></pre> <p>(I did try putting a "far" in there following string.h's example. No effect - and on this PIC I don't have 64K so really ought to recompile everything as 'near')</p> <p>The implementation in aprs.c is</p> <pre><code>void aprsMakeCallsignPgm(t_ax25Callsign *buffer, const rom char *callsign, unsigned char ssid) { int i = 0; volatile char ch; for(i=0; i&lt;6 &amp;&amp; (ch = callsign[i]) != 0; i++) { buffer-&gt;callsign[i] = ch &lt;&lt; 1; } for( ; i&lt;6; i++) { buffer-&gt;callsign[i] = (' '&lt;&lt;1); } buffer-&gt;flags.value = 0; buffer-&gt;flags.ssid = ssid; } </code></pre> <p>(It could be optimised. Best get this working first. This implementation lets me see what's in ch as it goes round the loop.)</p> <p>A couple of calls from main() in main.c are</p> <pre><code>aprsMakeCallsignPgm(&amp;(s_packet.address.from), "M0RJC", (unsigned char)9); aprsMakeCallsignPgm(&amp;(s_packet.address.to), "APRS", 0); s_packet.address.to.flags.isLast = 1; strcpypgm2ram(s_packet.message, "Hard coded test message"); </code></pre> <p>That cast to (unsigned char) didn't help either.</p> <p>The first three lines compile, but when run in the MPLAB simulator produce gibberish in the arguments in the function implementation.</p> <p>The strcpy line gives a compiler warning "Warning [2066] type qualifier mismatch in assignment". It would be nice if it told me which assignment.</p> <p>What have I done wrong here?</p> <p>Thanks</p> <ul> <li>Richard</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload